- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: Problem with a variable in my short shell scri...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-14-2007 08:56 AM
тАО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[2]: TROUPERS^M: This is not an identifier.
The first 2 lines of the shell script sets a variable:
TROUPERS=/home/TROUPERS
export TROUPERS
The file is set to 777. Any ideas folks? Thanks in advance.
Very Respectfully,
Chris Elmore
Solved! Go to Solution.
- Tags:
- variable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-14-2007 09:06 AM
тАО04-14-2007 09:06 AM
Solution#!/usr/bin/sh
export TROUPERS=/home/TROUPERS
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, ...).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-14-2007 09:13 AM
тАО04-14-2007 09:13 AM
Re: Problem with a variable in my short shell script
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?
v/r,
Chris
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-14-2007 09:20 AM
тАО04-14-2007 09:20 AM
Re: Problem with a variable in my short shell script
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!
v/r,
Chris
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-14-2007 09:33 AM
тАО04-14-2007 09:33 AM
Re: Problem with a variable in my short shell script
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.
MK
- Tags:
- dos2ux
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-14-2007 09:35 AM
тАО04-14-2007 09:35 AM
Re: Problem with a variable in my short shell script
/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
#!/usr/bin/sh
export VAR=somevalue
...
...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-14-2007 01:36 PM
тАО04-14-2007 01:36 PM
Re: Problem with a variable in my short shell script
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!
Very Respectfully,
Chris Elmore