Wednesday, January 23, 2013

How to create scripts

A script is a text file containing a command line that can be executed when the script is executed. So, the script file functions as an executable file for the command.

The general form of an executable script is

#!/bin/bash

the-command-line-here

If the command is meant to display an output in a terminal

#!/bin/bash

gnome-terminal -e "the-command-line-here"
But the terminal would close with the command and the output will not be seen. So, go to Edit -> Profile Preferences -> Title. Click the Command tab. Select Hold the terminal from the drop-down menu labelled When command exits.

Useful scripts:
  •  the printer status (outputs 2 numbers if ok)
#!/bin/bash

gnome-terminal -e "/etc/init.d/ccpd status"

No comments:

Post a Comment