- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Convert Perl Screpit into Shell
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
05-24-2009 12:48 AM
05-24-2009 12:48 AM
Array is My problem i couldnt code it in shell
#!/opt/OV/bin/Perl/bin/perl
@nodes = `/opt/OV/bin/OpC/utils/opcnode -list_nodes | grep Name | cut -f 11 -d " " | grep -v MGTSV`;
chomp(@nodes);
# ping nodes to check theis status
use Net::Ping ;
$p = Net::Ping->new("icmp");
foreach $host (@nodes)
{
$mon = 1 ;
$mon = 0 unless $p->ping($host, 5);
if ( $mon == 0 )
{
$mon = 1;
$mon = 0 unless $p->ping($host, 15);
}
system `/opt/OV/bin/OpC/opcmon check_node_status=$mon -object $host`;
}
$p->close();
Can anyone help me please
Salman A AlBedaiwi
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2009 06:14 AM
05-24-2009 06:14 AM
Re: Convert Perl Screpit into Shell
why do you want to do this?
If this script is working: use it as it is or modify it to meet your needs (e.g. setup a list which is NOT a result of an OpC-command).
If this script is not working: tell us about the error message. I suspect this construction:
system `/opt/OV/bin/OpC/opcmon check_node_status=$mon -object $host`;
The combination of backtic and the system command seems strange: the system would execute the string returned by the opcmon command ...
If you make yourself clear - write it down! - what this script is doing, it won't be a problem to use any (scripting) language to get it working.
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2009 06:26 AM
05-24-2009 06:26 AM
Re: Convert Perl Screpit into Shell
All that is happening here is that a list of hosts is being 'ping'ed; first with a 5-second timeout; and then (if that fails) with a 15-second timeout. The status of the ping is then passed to an external script called 'opcmon'.
This is definitely more robust in Perl than in a shell script. The construction of the '@nodes' array is decidedly un-Perlish. You could do:
my ($fh, @nodes);
open( $fh, "-|", "opt/OV/bin/OpC/utils/opcnode -list_nodes" ) or die;
while (<$fh>) {
next if /MGTSV/;
my @fields = split;
push @nodes, $fields[10];
}
...
That is, Perl counts 0-relative, so field-11 in your spawned process (the 'cut') is field-10 when done in Perl.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2009 08:08 AM
05-24-2009 08:08 AM
SolutionOops, I dropped the match for "Name":
my ($fh, @nodes);
open( $fh, "-|", "opt/OV/bin/OpC/utils/opcnode -list_nodes" ) or die;
while (<$fh>) {
next unless /Name/;
my @fields = split;
next if /MGTSV/;
push @nodes, $fields[10];
}
...
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2009 10:51 PM
05-24-2009 10:51 PM
Re: Convert Perl Screpit into Shell
e.g. set -A hosts ` your code `
This creates an array starting with ${host[0]} and with ${#host[*]} entries.
If the hosts are separated by commas, the you will have to use the FS variable to split it correctly. Make sure to save the previous value before changing, then restore afterwards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2009 06:54 AM
06-11-2009 06:54 AM
Re: Convert Perl Screpit into Shell
it was taking so many times to run again due to increasing the number of nodes i take out some nodes to let it be checked by other script so i make them working in together and my problem solved
thank allot for all of you
Salman A AlBedaiwi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2009 11:17 PM
06-11-2009 11:17 PM
Re: Convert Perl Screpit into Shell
you should take look at
http://forums13.itrc.hp.com/service/forums/helptips.do?#33
It's a good practise here in our forum...
mfG Peter