LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-31-2018, 10:51 AM   #1
bkelly
Member
 
Registered: Jan 2008
Distribution: Centos 7-4
Posts: 205

Rep: Reputation: 13
shebang error


I am running a network boot version of Centos. All the people that know anything about it are out for an extended period.

My bash scripts all start with this first line:
Code:
#!/bin/bash
Every time a script is run the monitor looks like this:

Quote:
bash-4.25 ./test_for.sh
./test_for.sh: line1: #!/bin/bash: No such file or directory
So do this:

Quote:
bash-4.25 ls -al /bin/ba*
-rwxr-xr-x 1 root root 32352 Apr 10 21:35 /bin/base64
-rwxr-xr-x 1 root root 29032 Apr 10 21:35 /bin/basename
-rwxr-xr-x 1 root root 964544 Apr 10 17:35 /bin/bash
lrwxrwxrwx 1 root root 10 Jun 11 16:27 /bin/bashbug -> bashbug-64
-rwxr-xr-x 1 root root 6964 Apr 10 17:52 /bin/bashbug-64
-rwxr-xr-x 1 root root 137 Apr 10 17:13 /bin/batch
As I read it, everything is in place.
This error might be related to this thread:

https://www.linuxquestions.org/quest...04#post5898404

But to the best of my ability bash is working as it should.
Are there any suggestions as to what this might be trying to tell me?

Last edited by bkelly; 08-31-2018 at 11:10 AM. Reason: typo
 
Old 08-31-2018, 11:04 AM   #2
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,883
Blog Entries: 13

Rep: Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931
As I read it, you have two bash executable files in your /bin directory, of different sizes:
Code:
bash-4.25 ls -al /bin/ba*
-rwxr-xr-x 1 root root 32352 Apr 10 21:35 /bin/base64
-rwxr-xr-x 1 root root 29032 Apr 10 21:35 /bin/basename
-rwxr-xr-x 1 root root 964544 Apr 10 17:35 /bin/bash
lrwxrwxrwx 1 root root 10 Jun 11 16:27 /bin/bashbug -> bashbug-64
-rwxr-xr-x 1 root root 6964 Apr 10 17:52 /bin/bashbug-64
-rwxr-xr-x 1 root root 137 Apr 10 17:13 /bin/bash
I would determine what the problem is there first. These are both files, no links. Both have 755 permissions.
 
Old 08-31-2018, 11:10 AM   #3
bkelly
Member
 
Registered: Jan 2008
Distribution: Centos 7-4
Posts: 205

Original Poster
Rep: Reputation: 13
Aw crum. that last entry should have been batch rather than bash. When I attempted to proof read I saw "bach" and rather than adding a "t" is changed the c to s.
The OP has been corrected and my apologies

Last edited by bkelly; 08-31-2018 at 11:12 AM.
 
Old 08-31-2018, 11:11 AM   #4
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,153

Rep: Reputation: 1265Reputation: 1265Reputation: 1265Reputation: 1265Reputation: 1265Reputation: 1265Reputation: 1265Reputation: 1265Reputation: 1265
Did you create the script on Linux or Windows?
 
1 members found this post helpful.
Old 08-31-2018, 11:16 AM   #5
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,872
Blog Entries: 1

Rep: Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871
Yes this must be some invalid character problem like BOM or CR.
https://www.linuxquestions.org/quest...0/#post5725686

Last edited by NevemTeve; 08-31-2018 at 11:21 AM.
 
Old 08-31-2018, 11:41 AM   #6
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,883
Blog Entries: 13

Rep: Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931
What smallpond and NevemTeve said.

If you have dos2unix on your system, use that to convert the file.

Or if you have hexdump you can dump the script and see for yourself if it has 0d 0a or just 0a [(CR LF) = DOS or (LF) = Unix/Linux]
 
Old 08-31-2018, 12:49 PM   #7
bkelly
Member
 
Registered: Jan 2008
Distribution: Centos 7-4
Posts: 205

Original Poster
Rep: Reputation: 13
You are on to something.
When I hex dump that file the first three characters are, in hex, EF BB BF

Created a new file from scratch and the first three are: 23 21 2F These are the #!/

I cannot imagine where those three byte came from. The Linux box and the Windows box are two completely separate computers. I cannot move any data from either one to the other. When the first few lines of the errant file are deleted and save, those three lines remain. When the cursor is put then home puts the cursor on the # and end puts it on the h of bash.

So for all my scripts I must start a new file and copy the text in from the old, skipping the first line or two and entering those by hand.

So this is resolved.
Thank you.
 
Old 08-31-2018, 02:13 PM   #8
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,872
Blog Entries: 1

Rep: Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871Reputation: 1871
https://en.m.wikipedia.org/wiki/Byte_order_mark
 
  


Reply



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
Which shebang to use for portable shell scripts dugan Programming 10 11-25-2014 08:46 PM
Script - shebang question laki47 Linux - Newbie 26 04-21-2013 08:26 PM
Init scripts shebang lincoln.runwal Linux - Newbie 1 03-25-2009 05:22 AM
shebang -e argument Shwick Linux - Software 1 10-16-2008 09:54 PM
Help with shebang hammertime1983 Programming 11 11-06-2007 02:17 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:53 AM.

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