Results 1 to 10 of 10
Can anyone help me explain this issue?
I tried moving a working script from one SUSE linux system to another and now it crashes on this line:
olx8:/usr/odir # more ...
- 02-06-2008 #1Just Joined!
- Join Date
- Jul 2004
- Posts
- 15
bad interpreter when running `dirname $0` in sh script
Can anyone help me explain this issue?
I tried moving a working script from one SUSE linux system to another and now it crashes on this line:
olx8:/usr/odir # more test.sh
#!/bin/sh
DIRNAME=`dirname $0`
olx8:/usr/odir # ./test.sh
: bad interpreter: No such file or directory
olx8:/usr/odir # which sh
/bin/sh
- 02-06-2008 #2
To help narrow this down, what is the output when you do these two commands?
Code:which bash od -t x1 test.sh
--
Bill
Old age and treachery will overcome youth and skill.
- 02-06-2008 #3Linux Enthusiast
- Join Date
- Aug 2006
- Posts
- 631
I'm afraid you have some wrong characters in your script. Does the lines end with CR/LF?
This can happen if you moved the scripts with ftp with a wrong mode (to Windows and back to Linux).
Regards
- 02-06-2008 #4
Yes, that's what I'm expecting. But I'm hoping he can do the od and post the results so I can show him a little bit about the ASCII character set.
--
Bill
Old age and treachery will overcome youth and skill.
- 02-06-2008 #5Just Joined!
- Join Date
- Jul 2004
- Posts
- 15
thanks SO much guys for helping me....
here is what I get on that:
olx8:/usr/odir # od -t x1 test.sh
0000000 23 21 2f 62 69 6e 2f 73 68 0d 0a 0d 0a 44 49 52
0000020 4e 41 4d 45 3d 60 64 69 72 6e 61 6d 65 20 24 30
0000040 60 0d 0a 0d 0a
0000045
olx8:/usr/odir # which bash
/bin/bash
olx8:/usr/odir #
- 02-06-2008 #6Just Joined!
- Join Date
- Jul 2004
- Posts
- 15
ahhh! thanks you guys! typing "dos2unix test.sh" seems to have fixed it.
thank you sooo much!
- 02-06-2008 #7
ASCII school
The 0d is the "return" or "carriage return" character. In the old days of teletypes, that character would cause the print element to return to the left edge of the paper. In the even older days when print elements stood still and the paper moved, the carriage which held the paper would move to the right. That's where the "C" in "CR" comes from.Code:0000000 23 21 2f 62 69 6e 2f 73 68 0d 0a 0d 0a 44 49 52 0000020 4e 41 4d 45 3d 60 64 69 72 6e 61 6d 65 20 24 30 0000040 60 0d 0a 0d 0a 0000045
But that didn't move the paper to the next line. Oh, no, that would be too simple. For that, you needed 0a, which is the "line feed" character. It would feed the paper forward for the distance of one line.
These days, Microsoft-compatible text files use <CR><LF> to mean end of line, as in your original troublesome file. UNIX and friends use <LF> only, I guess on the theory that it's easier to deal with one end of line character than two. (So this left the extra <CR> in your file as (supposed) real data, to fret over.) And Macintosh uses <CR> only.
Go figure.--
Bill
Old age and treachery will overcome youth and skill.
- 02-06-2008 #8Linux Engineer
- Join Date
- Apr 2006
- Location
- Saint Paul, MN, USA / CentOS, Debian, Solaris, SuSE
- Posts
- 1,117
Welcome - get the most out of the forum by reading forum basics and guidelines: click here.
90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
We look forward to helping you with the challenge of the other 10%.
( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )
- 02-06-2008 #9
Oooo, thanks for the update! I have a question, then.
Suppose you have an old-style text file. Will OS X read it properly? What about a <CR><LF> type file: Will OS X read that properly? How about OS 9?--
Bill
Old age and treachery will overcome youth and skill.
- 02-07-2008 #10Linux Engineer
- Join Date
- Apr 2006
- Location
- Saint Paul, MN, USA / CentOS, Debian, Solaris, SuSE
- Posts
- 1,117
Hi, Bill.
Those situations are why I keep this around:
OS X is unix, for all practical purposes, at the command line ... cheers, drlCode:% convert convert file contents by one of the following methods: addcr - adds a carriage return (^M) in front of every line feed (^J) delbs - deletes backspaces and bold or underline characters delcr - deletes carriage returns from file delff - deletes form feeds from file b2ul - converts boldface text in nroff output to underlined cr2lf - converts carriage returns to line feeds lf2cr - converts line feeds to carriage returns indent - indents text 5 spaces sp2tab - converts spaces to tabs via "unexpand"
Welcome - get the most out of the forum by reading forum basics and guidelines: click here.
90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
We look forward to helping you with the challenge of the other 10%.
( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )


Reply With Quote
