- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- CSH Scripting
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
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
тАО11-17-2000 10:22 AM
тАО11-17-2000 10:22 AM
This is what I tried:
ITEM[1]=YES
ITEM[2]=NO
ITEM[3]=MAYBE
@ COUNT = 1
echo "ITEM[$COUNT]
exit
the following is what is diplayed:
ITEM[1]=YES: No Match.
Thanks,
Ron
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-17-2000 11:00 AM
тАО11-17-2000 11:00 AM
Re: CSH Scripting
try
set ITEM=PLACEHOLDER
set ITEM[1]=YES
set ITEM[2]=NO
set ITEM[3]=MAYBE
set COUNT=1
echo "$ITEM[$COUNT]"
good luck
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-17-2000 11:03 AM
тАО11-17-2000 11:03 AM
Re: CSH Scripting
set var[1]="yes"
However, try and set var[2] and see what you get. It should be something like...
"set: Subscript out of range.".
In order to use arrays, you need to use Korne or Borne shell.
Good luck!
Shannon
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-17-2000 11:05 AM
тАО11-17-2000 11:05 AM
Re: CSH Scripting
I want 10 points!
% make love
Make: Don't know how to make love. Stop.
% got a light?
No match.
% sleep with me
bad character
% man: Why did you get a divorce?
man:: Too many arguments.
% rm God
rm: God nonexistent
% make 'heads or tails of all this'
Make: Don't know how to make heads or tails of all this. Stop.
% make sense
Make: Don't know how to make sense. Stop.
% make mistake
Make: Don't know how to make mistake. Stop.
% make bottle.open
Make: Don't know how to make bottle.open. Stop.
% \(-
(-: Command not found.
% rm -i God
rm: remove God? y
% ls God
God not found
% make light
Make: Don't know how to make light. Stop.
% date me
You are not superuser: date not set
Thu Aug 25 15:52:30 PDT 1988
% man rear
No manual entry for rear.
% If I had a ) for every dollar Reagan spent, what would I have?
Too many )'s.
% * How would you describe George Bush
*: Ambiguous.
% %Vice-President
%Vice-President: No such job.
% ls Meese-Ethics
Meese-Ethics not found
% "How would you rate Reagan's senility?
Unmatched ".
% [Where is Jimmy Hoffa?
Missing ].
% ^How did the^sex change operation go?
Modifier failed.
% cp /dev/null sex;chmod 000 sex
% more sex
sex: Permission denied
% mv sex show
% strip show
strip: show: Permission denied
% who is my match?
No match.
% set i="Democratic_Platform";mkdir $i;chmod 000 $i;ls $i
Democratic_Platform unreadable
% awk "Polly, the ship is sinking"
awk: syntax error near line 1
awk: bailing out near line
% %blow
%blow: No such job.
% 'thou shalt not commit adultery'
thou shalt not commit adultery: Command not found.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-17-2000 11:12 AM
тАО11-17-2000 11:12 AM
SolutionI'm no csh expert, but I think I see the problem--you need to initialize ITEM[] like this:
set ITEM=(YES NO MAYBE)
As far as I can tell, that's the only way to initialize and fill an array with values in one step. And don't forget the '$' in '$ITEM[$COUNT]' when you 'echo' the results.
I haven't even touched C shell in a long time. I'm just cheating by looking in my copy of _Unix_in_a_Nutshell_.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-17-2000 11:20 AM
тАО11-17-2000 11:20 AM
Re: CSH Scripting
set count = 1
set ITEM = (yes no maybe)
while ( $count < '4')
echo "ITEM["$count"]="$ITEM[$count]
@ count = $count + 1
end
exit 0
Here is the output:
ITEM[1]=yes
ITEM[2]=no
ITEM[3]=maybe
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-17-2000 11:21 AM
тАО11-17-2000 11:21 AM
Re: CSH Scripting
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-17-2000 11:27 AM
тАО11-17-2000 11:27 AM
Re: CSH Scripting
Regular *Bourne* shell doesn't support arrays (but the POSIX shell does); C shell, as far as I know, has always had arrays:
batwing 21: set ITEM=(YES NO MAYBE)
batwing 22: echo $ITEM[1]
YES
batwing 23: echo $ITEM[2]
NO
batwing 24: echo $ITEM[3]
MAYBE
batwing 25:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-17-2000 11:30 AM
тАО11-17-2000 11:30 AM
Re: CSH Scripting
set ITEMS = (one two three)
worked.
Thanks again,
Ron
Anyone know of a good books on UNIX scripting?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-17-2000 12:17 PM
тАО11-17-2000 12:17 PM
Re: CSH Scripting
I would imagine HP's "Shells: User's Guide" (viewable at http://docs.hp.com in HTML or PDF format) would be a pretty good place to start, too.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-17-2000 12:22 PM
тАО11-17-2000 12:22 PM
Re: CSH Scripting
set CAR = ( 1 2 3 4 5 6 7 8 9 10 )
will give you a 10 number array.
echo $CAR
1 2 3 4 5 6 7 8 9 10
echo $#CAR
10
then you can define the indivuduals.
Sorry again for answering in haste. C-shell is a pain in the #$%^&* for scripting, so I quit using it a couple of years ago. Functions are so much nicer in Borne&Korn :)
Sincerely,
Shannon
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-17-2000 02:56 PM
тАО11-17-2000 02:56 PM
Re: CSH Scripting
http://my1.itrc.hp.com/cm/QuestionAnswer/1,1150,0xbb5e7e990647d4118fee0090279cd0f9,00.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-17-2000 02:58 PM
тАО11-17-2000 02:58 PM
Re: CSH Scripting
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-19-2000 11:17 PM
тАО11-19-2000 11:17 PM
Re: CSH Scripting
set x = ()
Sets this variable x as an array. You can then fill it. If you would like to use a loop or anything you can do something like:
set x = ($x $newval)
As mentioned in the previous posts you can set and fill this array in one step. Also you can always add new fields to the array. But you can't put in emty spots. Every field has to contain something.