Logan Linux,

On Wednesday July 09, 2003 07:42, Logan Linux wrote:
> Sorry,
>
> None of these worked. Still get the same error. Do the \n's show up in VI?
<snip>
> > >> Im getting an error when running a script
> > >>
> > >> : bad interpreter: No such file or directory
> > >
> > > If you ever see that in the shell, it means that the script you're
> > > running has DOS linefeeds in it.  Use either "dos2unix" or
> > > "tr -d '\n' < oldfile > newfile" to remove them.
<snip>

Try it with a "tr -d '\r' oldfile > newfile". Unix uses Line feeds not 
carriage returns.

To see the line endings I use "od -c filename"

Here's an example...

[EMAIL PROTECTED] brian]$ cat bin/script.sh
#!/bin/sh

echo "I'm a script"

exit 0
[EMAIL PROTECTED] brian]$ script.sh
: bad interpreter: No such file or directory
[EMAIL PROTECTED] brian]$ od -c bin/script.sh
0000000   #   !   /   b   i   n   /   s   h  \r  \n  \r  \n   e   c   h
0000020   o       "   I   '   m       a       s   c   r   i   p   t   "
0000040  \r  \n  \r  \n   e   x   i   t       0  \r  \n
0000054
[EMAIL PROTECTED] brian]$ tr -d '\r' < bin/script.sh > bin/script_nr.sh
[EMAIL PROTECTED] brian]$ od -c bin/script_nr.sh
0000000   #   !   /   b   i   n   /   s   h  \n  \n   e   c   h   o
0000020   "   I   '   m       a       s   c   r   i   p   t   "  \n  \n
0000040   e   x   i   t       0  \n
0000047
[EMAIL PROTECTED] brian]$chmod 755 bin/script_nr.sh
[EMAIL PROTECTED] brian]$ script_nr.sh
I'm a script
[EMAIL PROTECTED] brian]$

HTH.

-- 
Brian Ashe                                                     CTO
Dee-Web Software Services, LLC.                  [EMAIL PROTECTED]
http://www.dee-web.com/


-- 
redhat-list mailing list
unsubscribe mailto:[EMAIL PROTECTED]
https://www.redhat.com/mailman/listinfo/redhat-list

Reply via email to