- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- shell script to perl
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
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
тАО09-12-2006 01:04 AM
тАО09-12-2006 01:04 AM
i need to recreate a shell script into a perl one (so i can run it on Wintel)
my Perl knowledege is poor. can you help to recreate these lines?
*****************************************
TS=$(date "+DATE: %m/%d/%y TIME: %H:%M:%S")
# print TS to all check_* printers: ----------------------------#
for CHECK in `cat $DZL_ETC/dzl_check-dsm-jqm.cfg`
do
echo $TS | pdpr -x"-job-priority 0" -d $CHECK > /dev/null 2>&1
done
# verify if printout is succesful -------------------------------------#
sleep 10 # give the printers some seconds to finish
for CHECK in `cat $DZL_ETC/dzl_check-dsm-jqm.cfg`
do
if $(grep -q "$TS" $DZL_LOG/check_dsm_jqm/$CHECK)
then echo "$CHECK OK $TS"
else echo "$CHECK NOK $TS"
cat /dev/null > $DZL_LOG/check_dsm_jqm/$CHECK #empty file
fi
done
*****************************************
thanks to all
Solved! Go to Solution.
- Tags:
- Perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-12-2006 01:42 AM
тАО09-12-2006 01:42 AM
Re: shell script to perl
though you could get advise how to this port from ksh/Posix-SH to perl, I really recommend learning Perl.
The port of this script, which should be easy, is a good opportunity to do so.
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-12-2006 01:54 AM
тАО09-12-2006 01:54 AM
Re: shell script to perl
I agree with Peter. You should begin your journey learning Perl. You could start here:
http://perldoc.perl.org/perlintro.html
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-12-2006 04:19 AM
тАО09-12-2006 04:19 AM
Solutionhttp://perlmonks.org/index.pl?node_id=283154
--8<--- Untested translation
use strict;
use warnings;
my @now = localtime;
# Using braindead US date format is left as an exercise to the reader
my $TS = sprintf "DATE: %4d-%02d-%02d TIME: %02d:%02d:%02d", $now[5] + 1900, $now[4] + 1, @now[3,2,1,0];
# print TS to all check_* printers
my @cfg;
{ local @ARGV = ("$ENV{DZL_ETC}/dzl_check-dsm-jqm.cfg");
chomp (@cfg = <>);
}
foreach my $CHECK (@cfg) {
open my $pr, qq{pdpr -x"-job-priority 0" -d $CHECK >/dev/null 2>&1 |" or die "$_: $!\n";
print $pr "$TS\n";
close $tr;
}
# verify if printout is succesful
sleep (10); # give the printers some seconds to finish
foreach my $CHECK (@cfg) {
my $file = "$ENV{DZL_LOG/check_dsm_jqm/$CHECK";
local @ARGV = ($file);
print "$CHECK $TS ", (grep m/\b$TS\b/ => <>) ? "OK\n" : "NOK\n";
truncate $file, 0; # empty file
}
--->8---
Enjoy, Have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-13-2006 12:56 AM
тАО09-13-2006 12:56 AM
Re: shell script to perl
i have now this:
@jqm_tmp = `nmcp list | grep jqm | grep ids | grep -v hosts | cut -f1 -d","`;
print jqm_cfg "@jqm_tmp";
normally the result of 'nmcp ...' is something like:
dsm_fax01
dsm_fax03
dsm_mail01
dsm_01a
dsm_03b
but in the log file (jqm_cfg) i have something like:
dsm_fax01
dsm_fax03
dsm_mail01
dsm_01a
dsm_03b
do you know how can i remove the blank spaces before the words?
regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-13-2006 01:07 AM
тАО09-13-2006 01:07 AM
Re: shell script to perl
The Forum tends to obliterate your formatting unless you check the "retain formatting" box at the bottom of your post.
However, I think you want:
# print jqm_cfg @jqm_tmp;
...instead of the interpolated list (with double-quotes).
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-13-2006 01:09 AM
тАО09-13-2006 01:09 AM
Re: shell script to perl
All those blanks get lost in space here on ITRC unless you tick the Retain Format checkbox
That grep is so un-perl!
my @jqm_tmp = map { m/^\s*(.*?)\s*,/; $1 } grep { m/jqm/ && m/ids/ && !m/hosts/ } => `nmcp list`;
Enjoy, Have FUN! H.Merijn