Re: Can't execute a script
At 12:01 PM 9/9/2005, bob self wrote: I have a simple test script called 'scripttest' in /root/bin: -rwxr-xr-x 1 root wheel 121 Sep 9 14:55 scripttest my $PATH IS /sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/usr/X11R6/bin:*/root/bin* #!/bin/sh echo pinging #end of scripttest If I run which scripttest, I get /root/bin/scripttest But if I try to run this test script I get scripttest: Command not found. Why is that happening? Assuming you're using csh, did you rehash after creating the script? Did you try to execute it with it's full path? like: /root/bin/scripttest -Glenn thanks, Bob Self ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED] ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Can't execute a script
Glenn Dawson wrote: Assuming you're using csh, did you rehash after creating the script? Did you try to execute it with it's full path? like: /root/bin/scripttest -Glenn Yes, I did 'rehash'. I'm running tcsh as root, FreeBSD 6.0. Also, I ran /root/bin/scripttest and I still get command not found. ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Can't execute a script
On 9/9/2005 11:01, bob self seems to have typed: If I run which scripttest, I get /root/bin/scripttest But if I try to run this test script I get scripttest: Command not found. Its a stupid thought, but could you run which sh? ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Can't execute a script
At 12:49 PM 9/9/2005, bob self wrote: Glenn Dawson wrote: Assuming you're using csh, did you rehash after creating the script? Did you try to execute it with it's full path? like: /root/bin/scripttest -Glenn Yes, I did 'rehash'. I'm running tcsh as root, FreeBSD 6.0. Also, I ran /root/bin/scripttest and I still get command not found. with such a simple script, there's not much that can go wrong, but you'll see the same error message if the shell specified at the beginning of the script doesn't exist. -Glenn ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED] ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Can't execute a script
Peter A. Giessel wrote: On 9/9/2005 11:01, bob self seems to have typed: If I run which scripttest, I get /root/bin/scripttest But if I try to run this test script I get scripttest: Command not found. Its a stupid thought, but could you run which sh? [EMAIL PROTECTED]/bin# which sh /bin/sh oh yes, I'm running 6.0 BETA 4 ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Can't execute a script
Peter A. Giessel wrote: On 9/9/2005 11:01, bob self seems to have typed: If I run which scripttest, I get /root/bin/scripttest But if I try to run this test script I get scripttest: Command not found. Its a stupid thought, but could you run which sh? ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED] I also should mention that I have many other shell scripts in /root/bin and most of them work. I only have two that don't work besides this test script, but I can't see why they shouldn't work. Bob ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Can't execute a script
* bob self [EMAIL PROTECTED] [2005-09-09 15:01:25 -0400]: #!/bin/sh echo pinging #end of scripttest If I run which scripttest, I get /root/bin/scripttest But if I try to run this test script I get scripttest: Command not found. Why is that happening? I've seen something like this happen when there is a non-printing character on the shebang line (like a CTRL-G or similar). So instead of running /bin/sh, your shell tries to run /bin/sh^G -- which obviously doesn't exist. Can you run xxd /root/bin/scripttest and show us the output? If you don't have xxd on your system (it usually is packaged with Vim) you can try od -x /root/bin/scripttest. xxd/od will show right away if there is anything funky on the shebang line that shouldn't be there. thanks, Thomas -- N.J. Thomas [EMAIL PROTECTED] Etiamsi occiderit me, in ipso sperabo ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Can't execute a script
N.J. Thomas wrote: I've seen something like this happen when there is a non-printing character on the shebang line (like a CTRL-G or similar). So instead of running /bin/sh, your shell tries to run /bin/sh^G -- which obviously doesn't exist. Can you run xxd /root/bin/scripttest and show us the output? If you don't have xxd on your system (it usually is packaged with Vim) you can try od -x /root/bin/scripttest. xxd/od will show right away if there is anything funky on the shebang line that shouldn't be there. thanks, Thomas xxd scripttest: 000: 2321 2f62 696e 2f73 680d 0a65 6368 6f20 #!/bin/sh..echo 010: 2270 696e 6769 6e67 2e2e 2e2e 220d 0apinging.. ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Can't execute a script
bob self [EMAIL PROTECTED] writes: xxd scripttest: 000: 2321 2f62 696e 2f73 680d 0a65 6368 6f20 #!/bin/sh..echo ^^-- BAD NEWS It doesn't work on 5.4, either, or probably any Unixy OS. BTW, the base OS comes with hd for a similar display. ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Can't execute a script
* bob self [EMAIL PROTECTED] [2005-09-09 18:41:35 -0400]: 000: 2321 2f62 696e 2f73 680d 0a65 6368 6f20 #!/bin/sh..echo ^^ 010: 2270 696e 6769 6e67 2e2e 2e2e 220d 0apinging.. Yup, that's your problem. This file is a DOS text file, so its end of line is a crnl (0x0d 0x0a) instead of just nl (0x0a). Normally, that doesn't matter because most Unix utilities are multi-eol-format aware, but you can't have it in the shebang line because the OS interprets the extra carriage as part of the command, so it is looking for /bin/sh^M, which doesn't exist. Use a utility like dos2unix or some a decent text editor to convert this to a Unix file format and you'll be good to go. Thomas -- N.J. Thomas [EMAIL PROTECTED] Etiamsi occiderit me, in ipso sperabo ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Can't execute a script
I wasn't aware of the eol issue and don't know how the 0x0d got there, but I fixed it with 'dosunix' and it works now. Thanks, Bob ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Can't execute a script
N.J. Thomas [EMAIL PROTECTED] writes: Normally, that doesn't matter because most Unix utilities are multi-eol-format aware, but you can't have it in the shebang line because the OS interprets the extra carriage as part of the command, so it is looking for /bin/sh^M, which doesn't exist. Know any reason that shouldn't be fixed? POSIX requirement maybe? What software reads the whole shebang line? (The sh shell apparently reads at least part of it, but I suppose some library functions do too.) Should I write a PR on it? ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]