04-14-2007 08:56 AM
I am having some trouble with a basic shell script I am drafting and the error that is produced when I execute the script is this:
./Trp_Extract.sh: TROUPERS^M: This is not an identifier.
The first 2 lines of the shell script sets a variable:
The file is set to 777. Any ideas folks? Thanks in advance.
Solved! Go to Solution.
04-14-2007 09:06 AM
It's always wise to use a "shbang" line in a script so that the system knows which executable to run your script against (POSIX/Bourne/Korn shell, perl, awk, ...).
04-14-2007 09:13 AM
Good to chat with you again! I tried using the shbang and this is what I get:
interpreter "/usr/bin/sh" not found
sh: Trp_Extract.sh: not found.
Any ideas what I'm doing wrong?
04-14-2007 09:20 AM
Your export syntax was spot on! The variables are setting correctly now. I was going off of an older install doc and the format must not be compatible with our newer OS. Thanks a bunch! I still can't get the shbang to set though. Any ideas!
Your the BEST!
04-14-2007 09:33 AM
The '^M' suggests that there may be Windows-style end-of-line characters in the script that are confusing the shell.
If you use FTP to transfer the script from MS-Windows to HP-UX, remember to use ASCII transfer mode when transferring scripts. This will handle the line ending character conversion automatically.
Your script is apparently named "Trp_Extract.sh". Please run "dos2ux Trp_Extract.sh" to convert the line ending characters to Unix style.
By the way, it's a very bad habit to set file permissions to 777 whenever there's a problem. Someone may add a few commands of his/her own into your script... and when you run it, they are executed using your identity. A smart intruder uses this to build him/herself a back door to your account and then restore your original script.
755 is enough for a script. If it needs to be maintained by a group of people, then 775. Never 777.
04-14-2007 09:35 AM
/usr/bin/sh not found tells me that you might not be using HP-UX. If /usr/bin/sh were not on your HP-UX system then you would have a LOT of issues.
What operating system are you using?
Also, the line MUST be the very first line in the script and must be exactly as Clay posted it and it must start at the very beginning of the line.
# cat script
04-14-2007 01:36 PM
You folks are the best! Sure enough, the source of my woes was my new windows ssh ftp client that I was using... it was embedding garbage windows esc sequenses in all of my scripts. I fixed them in vi and all is well again. You folks are a real credit to the forums and I humbly thank you each and every one, for your rapid and thoughtful responses. Please take care folks!