LinuxQuestions.org
Review your favorite Linux distribution.
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 04-08-2010, 05:32 PM   #1
C_Blade
LQ Newbie
 
Registered: Apr 2010
Posts: 7

Rep: Reputation: 0
Exclamation "!#/bin/bash: No such file or directory"? When running a script


Hi so I'm a new Linux user and I was programming a script for class, which is a pretty simple script. I have already made it executable and when I call the program I type ./myscript so that isn't the problem. For some reason it has a problem with the way I typed my first line I believe. My script simply begins, right off the bat, with a

#!/bin/bash



Anyone know what the problem is? Any help would be extremely appreciated
 
Old 04-08-2010, 05:38 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,977
Blog Entries: 11

Rep: Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879
Hi, welcome to LQ!

Edited in windows? You may have a trailing '^M'


Cheers,
Tink
 
Old 04-08-2010, 05:55 PM   #3
C_Blade
LQ Newbie
 
Registered: Apr 2010
Posts: 7

Original Poster
Rep: Reputation: 0
Not exactly, I have a VirtualBox running Ubuntu, so the file has never been edited in any other format. Could I be missing a certain file for bin/bash? That wouldn't make any sense. But this command is required for scripts to run so I'm feeling a little hopeless at this point.
 
Old 04-08-2010, 05:57 PM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,977
Blog Entries: 11

Rep: Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879
What's the output of
Code:
which bash
and what's your current path
Code:
echo $PATH
?
 
Old 04-08-2010, 06:10 PM   #5
C_Blade
LQ Newbie
 
Registered: Apr 2010
Posts: 7

Original Poster
Rep: Reputation: 0
which bash:
Code:
/bin/bash
echo $PATH:
Code:
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
 
Old 04-08-2010, 06:11 PM   #6
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,977
Blog Entries: 11

Rep: Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879
Ok, that looks normal ....

Next question:

In your posts body you have
Code:
#!/bin/bash
In the subject line it says:
Code:
!#/bin/bash
Which is in your script?
 
Old 04-08-2010, 06:17 PM   #7
C_Blade
LQ Newbie
 
Registered: Apr 2010
Posts: 7

Original Poster
Rep: Reputation: 0
Okay, just know that this is the first script I wrote, and since I haven't been able to run it at all, I haven't got a chance to debug or figure out what was wrong in it. I think the first line is the most crucial problem =/

Code:
#!/bin/bash
while [ $# gt -1 ]
   if [ -f $1 ]
   then
      print STDERR "Error: first file exists"
   else
      print STDOUT "$1"
      print STDOUT "$2"
      shift
    fi
done
exit
 
Old 04-08-2010, 06:21 PM   #8
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,977
Blog Entries: 11

Rep: Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879
Except for the missing do under while and the fact that
"print" is not a bash command it looks OK.

Should work, is what they say (well, and the tests
need some honing).
 
Old 04-08-2010, 06:31 PM   #9
C_Blade
LQ Newbie
 
Registered: Apr 2010
Posts: 7

Original Poster
Rep: Reputation: 0
Yeah, when I call the program, it just says gives me:

Code:
./combine: line 1: !#bin/bash/: No such file or directory
Yeah so I can't figure it out, I'm guessing you haven't seen anything like this before either? Maybe I'll try to find a Linux computer on campus and try it there.
 
Old 04-08-2010, 06:37 PM   #10
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,977
Blog Entries: 11

Rep: Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879
Quote:
Originally Posted by C_Blade View Post
Yeah, when I call the program, it just says gives me:

Code:
./combine: line 1: !#bin/bash/: No such file or directory
Yeah so I can't figure it out, I'm guessing you haven't seen anything like this before either? Maybe I'll try to find a Linux computer on campus and try it there.

Now you produced a THIRD variant, which is wrong (similar
to the one in the subject):

It's
Code:
#!/bin/bash
not
Code:
#!bin/bash
 
Old 04-08-2010, 07:04 PM   #11
C_Blade
LQ Newbie
 
Registered: Apr 2010
Posts: 7

Original Poster
Rep: Reputation: 0
Ohhhhhh man... I made some terribly stupid mistakes with this code. I looked at examples over and over again and I swore I had everything in the right place.

Thank you so much Tinkster!!!!
 
Old 04-08-2010, 07:14 PM   #12
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,977
Blog Entries: 11

Rep: Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879Reputation: 879
Most welcome, and:
No worries - we all have those days ;}
 
Old 04-08-2010, 10:15 PM   #13
grail
Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 7,502

Rep: Reputation: 1893Reputation: 1893Reputation: 1893Reputation: 1893Reputation: 1893Reputation: 1893Reputation: 1893Reputation: 1893Reputation: 1893Reputation: 1893Reputation: 1893
Good to see your solution finally came about, please remember to mark as SOLVED.
 
  


Reply


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
Grep in bash script returns "No such file or directory", works manually gizza23 Programming 7 02-25-2010 04:37 PM
"bash: /usr/bin/git: No such file or directory " - why does bash look in /usr/bin babu198649 Linux - Newbie 7 07-16-2009 11:06 AM
LFS 6.2 Ch. 6.14 - 2nd Coreutils test returns "/bin.bash: No such file or directory" 0graham0 Linux From Scratch 2 08-23-2007 06:32 PM
How to write a bash script to replace all "KH" to "K" in file ABC??? cqmyg5 Slackware 4 07-24-2007 09:00 AM
cgi-bin: "attempt to invoke directory as script" hamish Linux - Software 0 12-09-2004 12:45 PM


All times are GMT -5. The time now is 02:39 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration