- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- cstm scripting like ftp 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
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
10-15-2001 01:59 AM
10-15-2001 01:59 AM
I'd like to add some standard commands to a script and output the result to file.
in ftp we'd have
ftp $HOST << EOFTP
ls
bin
prompt
mget *
bye
EOFTP
now I'd like to run a script
that'd in the case of cstm as an example run
cstm << EOCSTM > /tmp/out
map
cat /tmp/out| grep CPU | awk '{ print $1 }' > /tmp/cpu_id
for i in $(cat /tmp/cpu_id)
do
sel $i
info
done
EOCSTM
Now, the thing I'm having the problem with is adding script analysis to the application command. It seems to think that the commands are invalid, even though they work on standard input. Some of the commands work, those without the variable substitution.
An similar example would be like doing an ftp but say ftp'ing iles in binary or ascii let's say depending on their extension..
Any ideas?
Later,
Bill
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2001 02:19 AM
10-15-2001 02:19 AM
Re: cstm scripting like ftp scripting...
See if this works.
cstm << EOF > /tmp/out1$$
map
quit
OK
EOF
for i in `cat /tmp/out1$$|grep CPU |awk '{print $1}'`
do
echo $i
cstm << EOF >> /tmp/out2$$
sel device $i
infolog
quit
OK
EOF
cat /tmp/out2$$
rm /tmp/out1$$ /tmp/out2$$
done
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2001 02:26 AM
10-15-2001 02:26 AM
Re: cstm scripting like ftp scripting...
Small modification in the above. I am a bad cleaner.
....
infolog
quit
OK
EOF
done
cat /tmp/out2$$
rm /tmp/out1$$ /tmp/out2$$
---End of the Script---
You can use /tmp/out2$$ if you want somewhere.
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2001 02:29 AM
10-15-2001 02:29 AM
Re: cstm scripting like ftp scripting...
You'll have to do it in 2 stages, e.g.
========================================
cstm << EOCSTM > /tmp/out
map
EOCSTM
cat /tmp/out| grep CPU | awk '{ print $1 }' > /tmp/cpu_id
echo 'cstm << EOCSTM' > /tmp/cpu_id.out
for i in $(cat /tmp/cpu_id)
do
echo sel dev $i >> /tmp/cpu_id.out
echo infolog >> /tmp/cpu_id.out
echo done >> /tmp/cpu_id.out
done
echo EOCSTM >> /tmp/cpu_id.out
chmod 755 /tmp/cpu_id.out
/tmp/cpu_id.out
==========================================
Rgds, Robin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2001 02:53 AM
10-15-2001 02:53 AM
Re: cstm scripting like ftp scripting...
Did you actually try it?
I'm sure you'll see the same...
Here's one of your example scripts run with an set -x.
(I'm seeing the same on both examples)
cat /tmp/out| grep CPU | awk '{ print }' > /tmp/cpu_id
echo 'cstm << EOCSTM' > /tmp/cpu_id.out
for i in + cat /tmp/cpu_id
+ cat /tmp/cpu_id
cat: Cannot open /tmp/cpu_id: No such file or directory
do
echo sel dev >> /tmp/cpu_id.out
echo infolog >> /tmp/cpu_id.out
echo done >> /tmp/cpu_id.out
done
echo EOCSTM >> /tmp/cpu_id.out
chmod 755 /tmp/cpu_id.out
/tmp/cpu_id.out
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2001 04:17 AM
10-15-2001 04:17 AM
Re: cstm scripting like ftp scripting...
not sure on which release you are, my cstm does not have a "sel" command, but here goes (untested though!):
echo map\\nexit | cstm | grep CPU | awk '{ print "sel " $1 "\ninfo" }' && echo exit | cstm
This should do it, but I recommend to test
first:
echo map\\nexit | cstm | grep CPU
and
echo map\\nexit | cstm | grep CPU | awk '{ print "sel " $1 "\ninfo" }' && echo exit
Which output should look like the cstm-commandfile you like to have. Check out, if you really want to leave cstm with exit (the one I have did not know "done")
Hope this helps
Volker
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2001 04:30 AM
10-15-2001 04:30 AM
Re: cstm scripting like ftp scripting...
I think you will need two cstm runs in your script, one to get the /tmp/out file and another to run the cstm commands you extracted from the /tmp/out file. The latter part can be probably be done with something like:
{
...
echo $cstm_command1
...
echo $cstm_command2
...
echo done
} cstm
The "..." parts can be any shell commands/construct, including loops, etc., as long as the result get into the $cstm_command parameters.
All of this assumes that cstm has no problem with timing issues when reading from a non-interactive input. If it has, you will need something like the public domain 'expect' command as well.
I hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2001 05:21 AM
10-15-2001 05:21 AM
Re: cstm scripting like ftp scripting...
The first part is only to map. So, it works.
The second part is tricky as it calls sel and infolog. So dependending on the version of cstm you have, you may need to replace the corresponding commands.
As long as we don't include normal shell commands within the markers of cstm, it should work.
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2001 05:29 AM
10-15-2001 05:29 AM
Re: cstm scripting like ftp scripting...
Is /tmp/out being created?
How about /tmp/cpu_id (are you missing the $1 in the awk print statement?).
Rgds, Robin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2001 05:48 AM
10-15-2001 05:48 AM
Re: cstm scripting like ftp scripting...
Have you already tried this?
echo 'selclass qualifier cpu;info;wait;infolog' | cstm > cstm.out
It gets the information for all the CPUs
I generally have aliases for this in .kshrc/.profile
cpucstm="echo 'selclass qualifier cpu;info;wait;infolog' | cstm "
memcstm="echo 'selclass qualifier memory;info;wait;infolog' | cstm "
All you need to get the information for CPU's in a log is
cpucstm > /tmp/cpucstm.out
for memory
memcstm > /tmp/memcstm.out
This works for STM versions as old as A.21.05
-HTH
Ramesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2001 06:53 AM
10-15-2001 06:53 AM
Re: cstm scripting like ftp scripting...
se sel class is no good.
cstm works normally, it's just the script that doesn't as shown above..
The $0 wasn't missing in the script.
I'll try again and post the script and output up.
Bill
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2001 06:58 AM
10-15-2001 06:58 AM
Re: cstm scripting like ftp scripting...
set -x
cstm << EOCSTM > /tmp/out
map
quit
OK
EOCSTM
cat /tmp/out
cat /tmp/out| grep CPU | awk '{ print $1 }' > /tmp/cpu_id
echo 'cstm << EOCSTM' > /tmp/cpu_id.out
for i in $(cat /tmp/cpu_id)
do
echo sel dev $i >> /tmp/cpu_id.out
echo infolog >> /tmp/cpu_id.out
echo done >> /tmp/cpu_id.out
done
echo EOCSTM >> /tmp/cpu_id.out
chmod 755 /tmp/cpu_id.out
/tmp/cpu_id.out
--
Execution:
# /tmp/scr1.ksh
+ cstm
+ 0<<
map
quit
OK
EOCSTM
cat /tmp/out
cat /tmp/out| grep CPU | awk '{ print }' > /tmp/cpu_id
echo 'cstm << EOCSTM' > /tmp/cpu_id.out
for i in + cat /tmp/cpu_id
+ cat /tmp/cpu_id
cat: Cannot open /tmp/cpu_id: No such file or directory
do
echo sel dev >> /tmp/cpu_id.out
echo infolog >> /tmp/cpu_id.out
echo done >> /tmp/cpu_id.out
done
echo EOCSTM >> /tmp/cpu_id.out
chmod 755 /tmp/cpu_id.out
/tmp/cpu_id.out
1> /tmp/out
---
cat /tmp/out
Version A.22.00
Product Number B4708AA
(C) Copyright Hewlett Packard Co. 1995-1998
All Rights Reserved
Use of this program is subject to the licensing restrictions described
in "Help-->On Version". HP shall not be liable for any damages resulting
from misuse or unauthorized use of this program.
cstm>map
kibo.grenoble.hp.com
Dev Last Last Op
Num Path Product Active Tool Status
=== ==================== ========================= =========== =============
1 system system () Information Successful
2 0 Bus Adapter (582) Information Successful
3 0/0 PCI Bus Adapter (782) Information Successful
4 0/0/0/0 Core PCI 100BT Interface Information Successful
5 0/0/1/0 PCI SCSI Interface (10000 Information Successful
6 0/0/1/1 PCI SCSI Interface (10000 Information Successful
7 0/0/1/1.15.0 SCSI Disk (SEAGATEST39102 Information Successful
8 0/0/2/0 PCI SCSI Interface (10000 Information Successful
9 0/0/2/1 PCI SCSI Interface (10000 Information Successful
10 0/0/2/1.15.0 SCSI Disk (SEAGATEST39204 Information Successful
11 0/0/4/0 RS-232 Interface (103c104 Information Successful
12 0/0/5/0 RS-232 Interface (103c104 Information Successful
13 0/2 PCI Bus Adapter (782) Information Successful
14 0/2/0/0 PCI Bus Adapter (10110026 Information Successful
15 0/2/0/0/4/0 PCI 4 Port 100BT LAN (101 Information Successful
16 0/2/0/0/5/0 PCI 4 Port 100BT LAN (101 Information Successful
17 0/2/0/0/6/0 PCI 4 Port 100BT LAN (101 Information Successful
18 0/2/0/0/7/0 PCI 4 Port 100BT LAN (101 Information Successful
19 0/4 PCI Bus Adapter (782) Information Successful
20 0/4/0/0 Unknown ()
21 0/6 PCI Bus Adapter (782) Information Successful
22 0/6/0/0 PCI WAN Performance Inter Information Successful
23 8 MEMORY (9b) Information Successful
24 160 CPU (5d5) Information Successful
25 162 CPU (5d5) Information Successful
cstm>quit
-- Exit the Support Tool Manager --
Are you sure you want to exit the Support Tool Manager?
Enter Cancel, Help, or OK: [OK] OK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2001 07:13 AM
10-15-2001 07:13 AM
Re: cstm scripting like ftp scripting...
the next command must follow within the same cstm session: info or else it won't work.
Bill
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2001 07:15 AM
10-15-2001 07:15 AM
SolutionIt's surprizing to see why it's not working for you. Can you try this with sh -x and see? Believe me. This works superbly on my system. Only thing is that you need to replace sel device with the one that is applicable to you. Try cstm manually to get the output and incorporate those commands.
//start
cstm << EOF > /tmp/out1$$
map
quit
OK
EOF
for i in `cat /tmp/out1$$|grep CPU |awk '{print $1}'`
do
echo $i
cstm << EOF >> /tmp/out2$$
sel device $i <== I think here it is sel $i
infolog <<== info??
quit
OK
EOF
done
cat /tmp/out2$$
rm /tmp/out1$$ /tmp/out2$$
//END
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2001 07:19 AM
10-15-2001 07:19 AM
Re: cstm scripting like ftp scripting...
You've got a trailing space after the closing
EOCSTM. Take it out, and it'll work!!
Rgds, Robin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2001 07:22 AM
10-15-2001 07:22 AM
Re: cstm scripting like ftp scripting...
You gotta watch out for copy paste jobs on the forums.!!!
Thanks,
Bill