HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Bash script from SCO doesn't work under RH ES 5
Operating System - Linux
1826614
Members
2998
Online
109695
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- 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
02-24-2009 06:44 AM
02-24-2009 06:44 AM
I am having a problem with one of our bash scripts we used on SCO that now don't work on our new platform RH ES 5.
In the following example I want INFILE to be set to the value of the last parameter that I pass to the script. Instead of this I get INFILE set to ‘1’ if I pass one parameter or ‘2’ if I pass 2 parameters to the script.
We use this syntax on SCO Unix in many scripts. Does anyone have any idea of a workaround or what the correct syntax should be?
--------------------------------------
#! /bin/bash
if [ "$#" != 0 ]
then
INFILE=`eval echo $"$#"`
echo $INFILE
fi
In the following example I want INFILE to be set to the value of the last parameter that I pass to the script. Instead of this I get INFILE set to ‘1’ if I pass one parameter or ‘2’ if I pass 2 parameters to the script.
We use this syntax on SCO Unix in many scripts. Does anyone have any idea of a workaround or what the correct syntax should be?
--------------------------------------
#! /bin/bash
if [ "$#" != 0 ]
then
INFILE=`eval echo $"$#"`
echo $INFILE
fi
Solved! Go to Solution.
1 REPLY 1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2009 08:34 AM
02-24-2009 08:34 AM
Solution
Your variables are getting interpolated multiple times and in the wrong order, so it's trying to expand $" as a variable too early. You need to escape the first dollar sign:
INFILE=`eval echo \\$"$#"`
But I think you could probably make it a little simpler with something like this:
eval INFILE="\$$#"
The different behaviors may be caused by different versions of bash. Newer versions are more strictly POSIX-compliant.
INFILE=`eval echo \\$"$#"`
But I think you could probably make it a little simpler with something like this:
eval INFILE="\$$#"
The different behaviors may be caused by different versions of bash. Newer versions are more strictly POSIX-compliant.
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Support
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP