The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 05-05-2006
Registered User
 

Join Date: May 2006
Posts: 1
question

hi
tellme how to do myown shell script
Reply With Quote
Forum Sponsor
  #2  
Old 05-05-2006
Registered User
 

Join Date: Apr 2006
Location: Italy
Posts: 1
With the keyboard? :-)
Reply With Quote
  #3  
Old 05-05-2006
RTM's Avatar
RTM RTM is offline
Hog Hunter
 
Join Date: Apr 2002
Location: On my motorcycle
Posts: 3,039
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 -
Reply With Quote
  #4  
Old 05-05-2006
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 4,297
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.
Reply With Quote
  #5  
Old 05-05-2006
vino's Avatar
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,698
I wonder what Gollum would have replied.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 10:23 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0