Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Distributions > Fedora
User Name
Fedora This forum is for the discussion of the Fedora Project.


  Search this Thread
Old 11-15-2004, 01:29 PM   #1
LQ Newbie
Registered: Aug 2004
Location: Arizona
Distribution: Fedora
Posts: 9

Rep: Reputation: 0
Angry Scripts failing with #!/bin/bash or other shell on first line

Have several scripts that start with #!/bin/bash or #!/bin/php or somthing similar to set the shell for the script.

All of these scripts terminate immediatly when started from a prompt unless the shell is specified on the command line.

[root@nsse ~]# ./testme
[root@nsse ~]#

[root@nsse ~]# bash ./testme
Hello World
[root@nsse ~]#

The testme script is as follows:

echo "Hello World"

The platform is FC3

Other than this one issue everything is running fine.

Old 11-15-2004, 02:19 PM   #2
Registered: Oct 2004
Location: Poland
Distribution: Slack 10.1, Mandrake 10.1
Posts: 118

Rep: Reputation: 15
Are you sure bash and others are in /bin/ ?
You can check it by typing :
which bash
Old 11-16-2004, 12:02 AM   #3
Registered: Aug 2004
Location: Sydney, Australia
Distribution: Debian Squeeze
Posts: 49

Rep: Reputation: 15
Thats what I have.
Old 11-16-2004, 01:16 AM   #4
Registered: Nov 2003
Location: Diawang-awangan
Distribution: Ubuntu Hoary!
Posts: 319

Rep: Reputation: 30
Your test script works just fine on my FC3. Did you do an upgrade from previous release?
Old 11-16-2004, 02:06 PM   #5
Registered: Apr 2002
Location: Bronx, NY
Distribution: Ubuntu
Posts: 371

Rep: Reputation: 34
No problems on my FC3 either.
I can save the file in DOS text mode, but then I get:
: bad interpreter: No such file or directory
I can save the file without Execute permission, but then I get:
bash: ./testme: Permission denied

I have no idea what you're doing.
Old 11-16-2004, 04:33 PM   #6
LQ Newbie
Registered: Aug 2004
Location: Arizona
Distribution: Fedora
Posts: 9

Original Poster
Rep: Reputation: 0
Another piece of information that I did not think was relavent at the time but found that it is. All of these scripts are being run from a prompt or cron but they are located under /var/www/html directories. The directories they are in are owned by and executed by the same user. Moved the scripts out of these directories and everything works.
Old 11-16-2004, 07:46 PM   #7
Senior Member
Registered: Dec 2003
Location: Shelbyville, TN, USA
Distribution: Fedora Core, CentOS
Posts: 1,019

Rep: Reputation: 45
Did you do this first: chmod +x testme
That makes the file an executable file.
If you do ls -l testme and you see -rw-rw-r-- then you have not set it as executable
If you see -rwxrwxr-x then you should be able to use ./testme to run the script.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
bash shell script read file line by line. Darren[UoW] Programming 57 04-17-2016 06:07 PM
Bin Shell Scripts jcai Linux - Newbie 3 09-15-2004 06:15 PM
Feasibility of a compiler for shell scripts (BASH) mac48bit Linux - Newbie 2 08-16-2004 07:07 PM
bash shell scripts brisbois Linux - Newbie 3 02-17-2004 09:21 AM
Bash Shell Scripts Anthony Programming 2 03-29-2002 04:29 AM > Forums > Linux Forums > Linux - Distributions > Fedora

All times are GMT -5. The time now is 09:20 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration