[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: PHP Scripting - Hope you get all this



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...

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

echo "I'm a script"

exit 0
[brian hell brian]$ script.sh
: bad interpreter: No such file or directory
[brian hell 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
[brian hell brian]$ tr -d '\r' < bin/script.sh > bin/script_nr.sh
[brian hell 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
[brian hell brian]$chmod 755 bin/script_nr.sh
[brian hell brian]$ script_nr.sh
I'm a script
[brian hell brian]$

HTH.

-- 
Brian Ashe                                                     CTO
Dee-Web Software Services, LLC.                  rhlist dee-web com
http://www.dee-web.com/




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]