Results 1 to 8 of 8
Hi,
I'm new to linux and have a basic question.
I have created a shell script and made it executable with
Code:
chmod 755 my-script.sh
Looking at the permissions of ...
- 04-01-2007 #1Just Joined!
- Join Date
- Apr 2007
- Posts
- 10
Can't execute shell scripts (easy question)
Hi,
I'm new to linux and have a basic question.
I have created a shell script and made it executable with
Looking at the permissions of the file, it now reads...Code:chmod 755 my-script.sh
So I try to execute it using...Code:-rwxr-xr-x 1 jut jut 14 2007-04-01 00:22 my-script
wtf...Code:$ my-script -bash: my-script: command not found
- 04-01-2007 #2
Hi jut,
Welcome to the LinuxForums.
execute script like this
you have set executing bit already (chmod). ./my-script.sh will also work.Code:sh my-script.sh
It is amazing what you can accomplish if you do not care who gets the credit.
New Users: Read This First
- 04-01-2007 #3Linux User
- Join Date
- Feb 2006
- Posts
- 484
or like this
./my-script.sh
if you run your srcipts in "sh anyscript.sh" format you needn't change the permissions
- 04-02-2007 #4Just Joined!
- Join Date
- Apr 2007
- Posts
- 10
I have most definitely set the executable permissions, yet it still won't execeute....
Originally Posted by devils_casper
Look there's even an asterisks next to it! What's the deal....Code:jut@JPS:~$ ls -laFh -rwxr-xr-x 1 jut jut 14 2007-04-01 00:22 my-script*
- 04-02-2007 #5
what error does it throw?
post exact error message here.Code:./my-script sh my-script
It is amazing what you can accomplish if you do not care who gets the credit.
New Users: Read This First
- 04-02-2007 #6Just Joined!
- Join Date
- Apr 2007
- Posts
- 10
Code:jut@JPS:~$ more my-script #!/bin/sh ls jut@JPS:~$ my-sript -bash: my-sript: command not found jut@JPS:~$ sh my-script asdf backmeup backup_script_old foundmp3s jill juts_files.tar.gz MP750.zip my-script pix setup_files stuff-that-runs-when-i-start-this-linux-box zspw automate_scp backup_script Desktop jack jut_bkup.iso mp3 mypix.tar.gz PIC programs some-deep-folder todo-list jut@JPS:~$
- 04-02-2007 #7
sh my-script is working. if you prefix ./ before my-script, that will also work.
if you want to execute script without prefixing ./ or sh, you have to add path of folder having 'my-script' file in PATH variable.
Code:PATH=$PATH:<path_of_folder> my-script
It is amazing what you can accomplish if you do not care who gets the credit.
New Users: Read This First
- 04-02-2007 #8Just Joined!
- Join Date
- Apr 2007
- Posts
- 10
Oh that's interesting. Thanks!


Reply With Quote
