batch / scripts


echo $row['what_tha'];
A short while back I opened pico wrote some commands in a few files as I would type in the terminal then saved the files... then chmod 755 the files in my /usr/local/bin and rehashed and whaa laaa.....

things such as, I now have a dir command that is nothing more than ls -l ,
it's faster for me to type ls or dir ;-)

But I have a question?.... I want to trap and use options such as

myfile thisvar

and myfile grab (thisvar) so I can have a file named "edit" with something like:

sudo pico [thisvar]

I keep getting [cannot write out: permission denied] alot because I forget to sudo pico httpd.conf and other such files of that sudo nature... <grin>

anyone know ?
Although it's not really a bad idea to do it that way, it's cleaner to add aliases to your ~/.tcshrc (you may not have one but that's OK).

Here's a snippet from mine:
# Set prompt and prompt manipulation aliases
set hostname=`hostname`
alias setprompt 'set prompt="[${hostname}]`dirs|sed -e '\''s| .*||'\'' -e '\''s| .*[^/]\(/[^/]*/[^/]*\)|...\1|'\''`% "'

# Aliases so the cool prompt updates correctly
alias cd 'cd \!*; setprompt'
alias pushd 'pushd \!*; setprompt'
alias popd 'popd \!*; setprompt'

# Aliases for ease-of-use
alias telent 'telnet'
alias ls 'ls -l'

The first line gets the hostname of the machine. the second line makes an alias called 'setprompt' that's really just a shortcut that I use in the next section. The setprompt alias performs some magic so that my prompt looks like this:
That is, it keeps track of the host I'm logged into and the immediate two directories I'm in. The setprompt alias should be all one line (the next line is simply 'setprompt' which initially creates the custom prompt).

The next section creates aliases for the commands cd, pushd, and popd so that the prompt is updated correctly when I change directories or a//remove from the directory stack. You can see in those aliases how to pass an argument using \!* (the ';' means "execute the following command after the first one finishes).

You only have to use \!* if you're not appending the argument to the end of the alias, like in the 'ls' alias.

Take the snippet above and save it as ~/.tcshrc then type 'source .tcshrc' or close your terminal and open a new one.

Good luck,