Unix/Linux Go Back    


Shell Programming and Scripting Unix shell scripting - KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and shell scripts and shell scripting languages here.

How to execute shell Script?

Shell Programming and Scripting


Closed Linux or Unix Question    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 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 Unix and Linux 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 Unix and Linux 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 Unix and Linux 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 Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux 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 01:18 PM.