Click to See Complete Forum and Search --> : using bash - command not found


RedHat123
03-12-2004, 11:52 AM
why would a shell script work , but output :command not found also ?

scinerd
03-12-2004, 12:04 PM
because it errors on one line but will keep going. It's hard to say without seeing the script but my guess is your #!/bin/bash line has an error

for example this script


bas
echo "hi"


and outputs this
./test: line 1: bas: command not found
hi

RedHat123
03-12-2004, 12:09 PM
#!/bin/bash

echo "hello, $USER. I wish to list some files of yours"
echo "listing files in the current directory, $PWD"
ls # list files

output is
hello, root. I wish to list some files of yours
listing files in the current directory, /home/jobob
linux_notes.txt test.sh test.sh.txt upload web_root
: command not found
: command not found
: command not found



so it runs, sort of, but cant find something ????

RedHat123
03-12-2004, 12:12 PM
another simple example

#!/bin/bash

echo "hello"



output is
: command not found
hello
: command not found

blackrax
03-12-2004, 12:33 PM
add a parameter, -x, to #!/bin/bash - it will give you more verbose output.

mrBen
03-12-2004, 12:34 PM
What text editor are you using?

It looks like it is using the 'wrong' kind of line terminators.

Try removing all the blank lines from you scripts and see if they work then.

RedHat123
03-12-2004, 12:47 PM
Originally posted by mrBen
What text editor are you using?

It looks like it is using the 'wrong' kind of line terminators.

Try removing all the blank lines from you scripts and see if they work then.



THATS IT!

i suppose its one of those newbie "gotchyas"
i removed the few blank lines at the bottom, ran it and no problems this time

Im using vi (as well as notepad). i just copied my file over to my linux box, then was running from a shell on my windowz pc.

after i started having probs, i opened vi and edited. still had problems, until just now wheni removed the extra lines


thanks everyone

mrBen
03-12-2004, 12:59 PM
Ah yes. Notepad.

FYI Windows and Linux represent their line-feeds in different ways. Notepad, therefore, uses the Windows convention, but Linux will pick this up as a set of characters - I think ^M - without displaying them.

I've been there before, which was how I guessed.

Glad you got it sorted.

knute
03-12-2004, 01:12 PM
And the kicker with vi/m is that it will recognize it, and simply use dos compatability, and won't say anything or do anything to the file unless specifically told to.

RedHat123
03-12-2004, 01:18 PM
by the by, what is a good editor for use on a windowz pc for shell scripts ? one that wont inert extra little goodies at the end

bradfordgd
03-12-2004, 01:43 PM
To get rid of those little ^M if you see them, try this;

Open the file;

vi filename

then type the following;

<esc>:.,$s/<cntl>vm//g

where <cntl>vm is holding down the control key and typing "v" and then "m" with out releasing the control key. This will remove all of the carridge returns (^M) in the file. You can now save the file.

I've been there too...

the.spike
03-12-2004, 01:50 PM
An excellent text editor would have to be Ultra Edit. Check out www.ultraedit.com.

Edits all sorts of file, unix, mac dos and keeps them in the format they are meant to be in..

Will also "Open from FTP" meaning that if you have a logon to a particular unix box then you can open the file straight from it using FTP..

And check out the column editing.. this is the only program I've seen that does it and it's way cool..

spike...

blackrax
03-12-2004, 02:21 PM
Originally posted by RedHat123
by the by, what is a good editor for use on a windowz pc for shell scripts ? one that wont inert extra little goodies at the end

well, if you're already familiar with vim - then why not vim?