How to execute shell Script? | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


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

How to execute shell Script?

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 05-09-2002
siva siva is offline
Registered User
 
Join Date: Apr 2002
Last Activity: 15 May 2002, 1:49 AM EDT
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
How to execute shell Script?

I am new to UNIX , Can any one let me know how to execute shell script (i.e which command I have to use for the same).

Any help would be appreciated.
Thanks
siva
mymvs999@yahoo.com
Sponsored Links
    #2  
Old 05-09-2002
thehoghunter
Guest
 
Posts: n/a
If the script is in the directory you are in (man pwd)
% ./myscript

Also check the permissions - it should have r-x for the appropriate user ID (man chmod)
ls -l myscript
-rwx-r-x-r-x owner group size myscript

Or you can execute with the full path
% /yourfilestructure/yourscripts/myscript

Realize where it has your or my, it changes to whatever directory and path are correct for your system.
Sponsored Links
    #3  
Old 05-09-2002
Deepa Deepa is offline
Registered User
 
Join Date: Apr 2002
Last Activity: 4 October 2007, 12:33 AM EDT
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
%sh <shell-script>

should also work. Not sure if the same applies for all shells.
    #4  
Old 05-14-2002
usfrog usfrog is offline
Registered User
 
Join Date: Dec 2001
Last Activity: 9 July 2009, 9:28 PM EDT
Location: San Jose CA
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Lightbulb

As syntaxes differ from one shell to the other it's a good habit to specify the shell to be used in the first line of each script file.

Something like:
#!/usr/bin/ksh

Then you won't need to specify any shell on your command line - ie you'd just enter: ./myScript.sh
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Execute shell script without using sh sai_2507 Shell Programming and Scripting 7 04-19-2012 11:15 AM
How to use ssh execute other shell script on other host (shell script include nohup)? orablue Shell Programming and Scripting 1 11-18-2010 08:46 PM
How can I execute another shell from my ksh script? alexstar Shell Programming and Scripting 3 09-20-2010 09:06 AM
Execute unix shell script to text file using the script mastercar Shell Programming and Scripting 4 05-21-2010 05:32 AM
Is it possible to execute shell script with PHP? Micz Shell Programming and Scripting 1 05-27-2004 11:52 AM



All times are GMT -4. The time now is 08:11 PM.