![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
question
hi
tellme how to do myown shell script |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
With the keyboard? :-)
|
|
#3
|
||||
|
||||
|
As much as I like your answer Deepsoul...
It's simple - to do a script you have a choice of shells or languages - choose one that you are use to using (such as the shell you use normally - do a echo $SHELL to find out what you are using). Once you have that, cd to your home directory - vi a new file (such as my-new-script) $ cd $ vi my-new-script Insert the commands in the same order you would run them normally from the command line - only difference - add #!/bin/sh or whatever shell you are using at the top - this lets the system know what you are running these commands under #!/bin/sh /bin/cp /dirA/* /dirB/* exit Then use chmod as suggested to change the script to executable A script is putting all the commands you usually have to do into a file to run - it's doing what you would do automatically (via cron if needed). The only thing a script does it make it so you don't have to type those commands every time. Try this on your system: $ cd $ vi hbo i #!/bin/sh date +'%n %D %A %T%n' exit Hit the escape key, put in a wq to write-quit from the vi editor $ chmod 744 hbo $ ./hbo 01/18/05 Tuesday 19:44:04 $ That's all there is to it - |
|
#4
|
|||
|
|||
|
Your question is so basic, the only good answer is:
Get a basic book on unix - like the SAM's 'UNIX in 21 days' Learn: 1. basic command line syntax and some comands 2. how to edit a file 3. put some basic command(s) in a file, put execute privilege on the file, run it. |
|
#5
|
||||
|
||||
|
I wonder what Gollum would have replied.
|
||||
| Google The UNIX and Linux Forums |