Bash Script Beautifier

2010-12-23 1 min read bash Learning Linux
<dd class="wp-caption-dd zemanta-img-attribution" style="font-size: 0.8em;"> Image via <a href="http://en.wikipedia.org/wiki/File:Bash-org.png">Wikipedia</a> </dd> </dl> Today I was working on a bash script written by someone else. And the script was maintained since long and had actually become quite big and there was no indentation followed. So, you can understand how difficult it was to understand the script. So, I set my foot forth to first find a beautifier for the bash script before I fixed it and my search ended here. Continue reading

intercept stdout/stderr of another process or disowned process

2010-11-23 1 min read bash Fedora Linux
The command is definately going to save your day if you have disowned the process by mistake. Only uses strace so might as well work on Solaris also, though not tried it. intercept stdout/stderr of another process or disowned process 1 <td> <div class="text codecolorer"> strace -e write=1,2 -p $PID 2>&1 | sed -un "/^ |/p" | sed -ue "s/^.{9 }(.{50}).+/1/g" -e 's/ //g' | xxd -r -p </div> </td> </tr> Useful to recover a output(stdout and stderr) “disown”ed or “nohup“ep process of other instance of ssh. Continue reading

Broadcast your shell thru port 5000

2010-11-20 1 min read bash Fedora Linux
Broadcast your shell thru port 5000 1 <td> <div class="text codecolorer"> mkfifo /tmp/fifo;(nc -q0 -l 5000 < /tmp/fifo &);script -f /tmp/fifo </div> </td> </tr> run 1 <td> <div class="text codecolorer"> nc yourip 5000 </div> </td> </tr> elsewhere will produce an exact same mirror of your shell. This is handy when you want to show someone else some amazing stuff in your shell without giving them control over it. * View this command to comment, vote or add to favourites * View all commands by clvv Continue reading

Print all environment variables, including hidden ones

2010-11-09 2 min read bash Fedora Linux
Print all environment variables, including hidden ones 1 <td> <div class="text codecolorer"> for _a in {A..Z} {a..z};do _z=${!${_a}*};for _i in `eval echo "${_z}"`;do echo -e "$_i: ${!_i}";done;done|cat -Tsv </div> </td> </tr> This uses some tricks I found while reading the bash man page to enumerate and display all the current environment variables, including those not listed by the ‘env‘ command which according to the bash docs are more for internal use by BASH. Continue reading

bash script to run a command and take screenshot in every loop.

2010-09-24 2 min read bash Fedora Learning Linux
Couple of days back, I had posted a command to display a stop timer with bash and echo. There I had also put the following gif file: <img class="size-medium wp-image-2555" title="bash screenshot for the script output" src="http://blog.amit-agarwal.co.in/wp-content/uploads/2010/09/temp-300x170.gif" alt="bash screenshot for the script output" width="300" height="170" /> Here the tricky part was to capture the jpg&#8217;s to create the gif file. Preparation: Rename the terminal to aka – amit-capture Execute the command once with the import command and check the output and jpg&#8217;s Continue reading

bash – echo command with option to display the output on the same line.

2010-09-21 2 min read bash Fedora Learning Linux
Here is a nice little trick to display the output in the same line : 1 <td> <div class="bash codecolorer"> &nbsp;<span class="kw3">echo</span> <span class="re5">-ne</span> <span class="st0">"output\<span class="es1">\r</span>"</span> </div> </td> </tr> The trick here is simple, first we disable the <a class="zem_slink" title="Newline" rel="wikipedia" href="http://en.wikipedia.org/wiki/Newline">newline printed by <a class="zem_slink" title="Echo (command)" rel="wikipedia" href="http://en.wikipedia.org/wiki/Echo_%28command%29">echo command with the &#8221;-n&#8221; option and then we enable the interpretation of the <a class="zem_slink" title="Backslash" rel="wikipedia" href="http://en. Continue reading
Older posts Newer posts