- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Shell Problem
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
Forums
Discussions
Discussions
Discussions
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
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
06-22-2005 07:18 PM
06-22-2005 07:18 PM
Shell Problem
filesystem1[1]="north"
filesystem1[2]="south"
echo ${filesystem1[1]}
north
echo ${filesystem1[2]}
south
h=1
echo ${filesystem1[$h]}
north
((h=$h+1))
${filesystem1[$h]}
south
i=1
echo ${filesystem$i[$h]}
sh: ${filesystem$i[$h]}: The specified substitution is not valid for this command.
${filesystem"$i"[$h]}
sh: ${filesystem"$i"[$h]}: The specified substitution is not valid for this command.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2005 12:28 AM
06-23-2005 12:28 AM
Re: Shell Problem
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2005 01:02 AM
06-23-2005 01:02 AM
Re: Shell Problem
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2005 01:06 AM
06-23-2005 01:06 AM
Re: Shell Problem
filesystem$i
You can avoid this type of problem (by getting a useful error message) using the set -u option at the start of your script. Any time an undefined variable is referenced (ie, echo) the script will stop and identify the location.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2005 01:31 AM
06-23-2005 01:31 AM
Re: Shell Problem
He is trying to do this:
filesystem1[1]="north"
filesystem1[2]="south"
filesystem2[1]="east"
filesystem2[2]="west"
then referencing the SUBSCRIPTS of the variables
"filesystem1"
and
"filesystem2"
He wants this to happen:
$i=1
$h=2
echo $filesystem$i[$h]
producing "south" as output
or
$i=2
$h=1
echo $filesystem$i[$h]
producing "east" as output
live free or die
harry d brown jr
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2005 01:42 AM
06-23-2005 01:42 AM
Re: Shell Problem
Something like:
i=1
h=1
FS=filesystem${i}
echo ${FS[$h]}
north
i=2
h=2
FS=filesystem${i}
echo ${FS[$h]}
west
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2005 02:01 AM
06-23-2005 02:01 AM
Re: Shell Problem
Mark - nice to see your name on here again. Where've you been?
Mark Syder (like the drink but spelt different)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2005 02:14 AM
06-23-2005 02:14 AM
Re: Shell Problem
Outer Loop:-
prompt the user for a server name
Inner Loop:-
Prompt the user for filesystems (1 at a time in this inner loop)
When all input has been gathered I want to display the information on screen
e.g.
_______________________________________
Server:- "Server Name"
Filesystems:- "Filesystem" "Filesystem" ...
Server:- "Server Name"
Filesystems:- "Filesystem" " Filesystem" ...
etc...
_________________________________________
Hope this makes my problem clearer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2005 06:39 PM
06-23-2005 06:39 PM
Re: Shell Problem
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2005 12:12 AM
06-24-2005 12:12 AM
Re: Shell Problem
$ filesystem1[1]="north"
$ h=1
$ i=1
$ eval echo \${filesystem$i[\$h]}
north
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2005 11:04 PM
06-24-2005 11:04 PM
Re: Shell Problem
Brian.....Ermin's idea works.....