[plug] Need to learn basic scripting

bwarff bwarff at obsidian.com.au
Fri Jan 7 10:46:26 WST 2005


with simple scripting like that, all you need to do is put those lines into a file,
and make the file executable.

it also helps to tell the shell which interpreter to use (in this case itself),
you do this via a hash-bang trick on the first line of a file.

eg:

-----------------snip--------------------------
#!/bin/bash
ifconfig eth1 down
ifconfig eth1 up
ip route add default via 172.24.192.5 metric 0
smbmount //ptcpms01/data /home/user/Kdrive/ -o
username=XXXXXX%XXXXXXX,fmask=644,dmask=755,uid=1000,gid=100,debug=0,workgroup=XXXXXXXX
smbmount //wafile02/data /home/user/Idrive/ -o
username=XXXXX%XXXXXXX,fmask=644,dmask=755,uid=1000,gid=100,debug=0,workgroup=XXXXXXXXX
----------------end snip------------------------

if this file was called work-net.sh, then you would make it executable with
"chmod 700 work-net.sh"

then ./work-net.sh would run it...




On Fri, 7 Jan 2005 09:37:09 +0800
"Senectus ." <senectus at gmail.com> wrote:

> When I plug in at work I need to run these commands one after the
> other from the shell:
> ifconfig eth1 down
> ifconfig eth1 up
> ip route add default via 172.24.192.5 metric 0
> smbmount //ptcpms01/data /home/user/Kdrive/ -o
> username=XXXXXX%XXXXXXX,fmask=644,dmask=755,uid=1000,gid=100,debug=0,workgroup=XXXXXXXX
> smbmount //wafile02/data /home/user/Idrive/ -o
> username=XXXXX%XXXXXXX,fmask=644,dmask=755,uid=1000,gid=100,debug=0,workgroup=XXXXXXXXX
> 
> I'd like to run a script (like a batch file in windows) to help
> automate this and make it a bit quicker to log in.
> I'll be manually running it so it doesn't need to happen at boot or
> anything like that, but the real problem is that I have no idea where
> to start.
> I've been told that making a script is a simple easy thing to to do..
> can someone point me to a good "learn how to write scripts in linux
> for dummies" type web site?
> 
> -- 
> Ubuntu Warty 4.10
> _______________________________________________
> PLUG discussion list: plug at plug.linux.org.au
> http://spark.plug.linux.org.au/cgi-bin/mailman/listinfo/plug
> Committee e-mail: committee at plug.linux.org.au



More information about the plug mailing list