The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Making Executable File laxman123 AIX 0 06-12-2008 11:06 AM
How to make a script executable by all users? chrs0302 SUN Solaris 2 10-18-2005 09:46 AM
pls hlp: making .sh files executable ropers Filesystems, Disks and Memory 2 07-29-2002 02:44 AM
How do I make a cgi script World-executable tylerl UNIX for Dummies Questions & Answers 2 06-13-2001 02:29 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 06-29-2008
Registered User
 

Join Date: Jun 2008
Posts: 2
Making UNIX script executable

Hello,

I am very new to UNIX and I have been learning about writing scripts and making them executable. I created a script called myscript. It has three lines:
#! /bin/sh
# This is my first shell script
echo friendsjustfriends

Now I try to run it using the sh command and it works
Next I try to make it executable and it fails:

#! /bin/sh
# This is my first shell script
bash-3.2$ chmod u+x myscript
bash-3.2$ pwd ; echo $PATH
/Users/rohit
/usr/local/bin:/Users/rohit/bin:/usr/bin:/bin:/usr/sbin:/sbin
bash-3.2$ myscript
bash: myscript: command not found

I do not know why it is not working. If there is something wrong with the path, please let me know how to correct it.

Thank you so much!
Reply With Quote
Forum Sponsor
  #2  
Old 06-29-2008
Registered User
 

Join Date: Jan 2007
Posts: 6
Run it with ./myscript as its not in your PATH
Reply With Quote
  #3  
Old 06-29-2008
Registered User
 

Join Date: Jun 2008
Posts: 2
Thanks for your email.

How do I put in my path so that I do not need to use ./ to run it?

Thanks,

Rohit
Reply With Quote
  #4  
Old 06-29-2008
Technorati Master
 

Join Date: Mar 2005
Location: Large scale systems...
Posts: 2,610
You should start searching the forums. These had been answered many times before.

Anyway, here is a hint.

PATH=$PATH:/home/user/scripts/
Reply With Quote
  #5  
Old 07-01-2008
Registered User
 

Join Date: Jun 2008
Posts: 19
It's better practice to not put ./ into the PATH variable. Becuase it might be too confusing.
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 09:38 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