- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: query on perl - awk
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
тАО02-02-2003 07:09 PM
тАО02-02-2003 07:09 PM
Being a novice in perl forces me to raise hands ...
Any idea how do I correct the script:
The script looks like:
#!/opt/perl/bin/perl
`cksum "/home/vm/erlog" | (awk '{print $1}') > "/home/vm/erlog.cksum"`;
I found the awk does not function properly in this perl script.
thanks in advance.
Cheers !!!
Mathew.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-02-2003 07:37 PM
тАО02-02-2003 07:37 PM
Re: query on perl - awk
I'm no perl guru either, but the script runs fine for me. I used the cksum on the /var/adm/syslog.log file. Only thing I can think of is the version of perl your using. These are latest:
http://www.software.hp.com/cgi-bin/swdepot_parser.cgi/cgi/displayProductInfo.pl?productNumber=PERL
or
http://hpux.connect.org.uk/hppd/hpux/Languages/perl-5.8.0/
HTH
Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-02-2003 08:24 PM
тАО02-02-2003 08:24 PM
Re: query on perl - awk
Thanks for that ...
I have upgraded the perl version to 5.8.x from 5.6.1, now. but still no hope ...
I would like to know how can we specify a specific shell like the "k shell" to be used for these shell command in side the perl script.
Looks to me like it could be the posix shell issue.
Cheers !!!
Mathew.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-02-2003 08:42 PM
тАО02-02-2003 08:42 PM
SolutionTry the following: Replace $1 in your script with \$1
That should work.
Incidentally, when I invoked Perl with -w (enable warnings), I was able to easily determine the problem since Perl printed a helpful error message. I would recommend that you always execute Perl with -w. You can do this in your script with:
#!/opt/perl/bin/perl -w
Also, it is unclear to me why you are paranthesizing the awk command (awk ...). Doing so would invoke a subshell which in this case seems unnecessary.
Thanks.
Ajit
HP Gigabit Ethernet
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-02-2003 08:43 PM
тАО02-02-2003 08:43 PM
Re: query on perl - awk
What answer to you get?
I'm not sure going to Perl 5.8 is going to impact this. Just make sure you are running the perl you think you are runing. The script should work.
I suppose check awk too.
P
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-02-2003 08:49 PM
тАО02-02-2003 08:49 PM
Re: query on perl - awk
Yeah your suggestion could solve the issue ..
#!/opt/perl/bin/perl
`cksum "/home/vm/erlog" | (awk '{print \$1}') > "/home/vm/erlog.cksum"`;
d the issue..
Could this be something related with the POSIX shell or otherwise how did my earlier syntax did work for Michael? !!
Guys, many many thanks for that ..
Cheers !!!
Mathew.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-02-2003 08:57 PM
тАО02-02-2003 08:57 PM
Re: query on perl - awk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-03-2003 08:52 AM
тАО02-03-2003 08:52 AM
Re: query on perl - awk
#!/usr/bin/sh
cksum /home/vm/erlog | awk '{print $1}' > /home/vm/erlog.cksum
does the same as a *shell* script with less overhead. Not that I object to perl, as the regulars will know, but there's a good tool for everything, and - in this case - it ain't perl.
Enjoy, have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-03-2003 10:15 AM
тАО02-03-2003 10:15 AM
Re: query on perl - awk
Wrapping external commands like cksum *and* even awk in a Perl script isn't only silly but a waste of resources.
But if you want to do your checksumming in soley Perl you could do it like this:
use Digest::MD5;
open FH, '/your/file/to/checksum'
or die "cannot open";
$md5 = Digest::MD5->new;
$md5->addfile(*FH);
close FH;
$md5sum = $md5->hexdigest;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-03-2003 10:39 AM
тАО02-03-2003 10:39 AM
Re: query on perl - awk
How about this:
#!/opt/perl/bin/perl
$logfile="/home/vm/erlog.cksum";
open(file, ">>$logfile") || die "open $logfile for cksum append \n";
printf file "%d\n",`cksum /home/vm/erlog`;
live free or die
harry