If you write a lot of scripts to automate tasks, you probably already know this. However, if you don’t, and you are still reading, you are probably a programmer, in which case, you really should be learning how to script in BASH!
A couple of pointers for you:
1. Using a -x, in the shebang line “echo”s every line before executing. This turns out to be quite useful for debugging shell scripts
2. It’s quite easy to make BASH print a countdown.
Posted by Shiva at 8:06 pm on August 28th, 2011.
Categories: Tech. Tags: countdown, debug, echo, same line, scripting, shell, shell scripting, unix.
In *nix systems, you can make the display, the GUI of an application, appear on another machine. This if often required, when the machine you want to run the application on is in a lab, and you have access through a desktop machine that has a monitor.
You can do this, by running an XServer on the desktop machine and configuring the client (the one where you run your app) with the XServer details. By default, the XServer instance on your desktop disallows communication from all machines except localhost. Thus, you will need to add the host in the allowed list using the xhost command.
On your machine, to disable security checks:
$ xhost +
To allow connections from a single host:
$ xhost +<hostname/ip>
On the client machine where the application is run, set the X Server to display to (for bash shell):
$ export DISPLAY=<hostname>:<displaynumber>.<screennumber>
If you haven’t changed the display-number or screen-number :
$ export DISPLAY=<hostname>:0.0
For a more detailed description of the
How to export your X Display.
Posted by Shiva at 11:48 am on June 21st, 2011.
Categories: Tech. Tags: how-to, Tips & Tricks, unix, X Display, xhost.
If you are not a UNIX user/not a geek, please turn away right now.
Every year, I either chance upon something new, or remind myself of something interesting that I’ve forgotten. This is the latter case. On a *NIX shell, you can push a foreground process to background (obviously without terminating it):
$ ./someprocess
...
...
...
Ctrl-Z
[1]+ Stopped ./someprocess
$ bg
[1]+ ./someprocess &
To bring the process into foreground:
$ fg < -- last process pushed into bkgnd
$ jobs <-- check active jobs
[1] ./someprocess
[2] ./someotherprocess
$ fg 2
via Job Control on UNIX systems.
Posted by Shiva at 2:21 pm on January 31st, 2011.
Categories: Tech. Tags: background process, bg, fg, job control, job control in unix, linux, push to background, unix.
Over the last few months, I have re-discovered some unix commands (it’s been such a long time)
- Eliminate duplicate lines from a file
#sort -u filename > filename.new
- List all lines that do not match a condition
#grep -v ajsk filename
- Copy contents of two files to one
#cat file1 file2 > file3
- Append output of a command to a file
#cat file1 >> file2
Posted by Shiva at 5:50 pm on September 9th, 2008.
Categories: Other. Tags: coding, unix, unix commands.