Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search results for query: *

  • Users: whn
  • Order by date
  1. whn

    How to efficiently implement file comparison

    Thank you, prex.
  2. whn

    Looking for a way to enhance the implementation

    Hi Feherke, Sorry for that I did not make myself clear. Let me restate my question: The hostname() may return one of the following four values: 1) foo 2) foo.xyz.com 3) foo.bar.xyz.com 4) foo.bar In either case, I want to return $from as foo@xyz.com or foo@bar.xyz.com in one-liner perl. Your...
  3. whn

    How to efficiently implement file comparison

    Let's say I have a baseline file like this: 4.1.27-4.1.2-amd64-1cccde6e81b2c42b cmos2q installed and running lm-sensors2q installed and running lspci2q installed and running mcelog2q installed and running mpt2q not needed pmbus2q installed and running smartmon2q installed and running And a...
  4. whn

    Looking for a way to enhance the implementation

    Hi Feherke, I want to follow up on this thread. Let's say hostname() returns a host w/o domain name like this: foo.bar. I have to admit this is a rare hostname and I have never seen it before. But it's possible, right? My question is how to still return the $from as 'foo@bar.xyz.com'? I...
  5. whn

    Looking for a way to enhance the implementation

    Thank you, Feherke, for your explanation. It helps a lot!
  6. whn

    Looking for a way to enhance the implementation

    Hi, Feherke, I have a follow-up question. Some people like one-liner because it's sophisticated. Some people hate it because it's hard to read and sometimes less efficient (e.g. one-liner to check a prime number). In the case above, getSender() vs. getSender2(), what's your opinion? Which way...
  7. whn

    Looking for a way to enhance the implementation

    I love it. Thank you, Feherke!
  8. whn

    Looking for a way to enhance the implementation

    I have a piece of codes constructing an email sender: sub getSender { my $host = hostname;a # use Sys::Hostname; my $domain = 'xyz.com'; my $char = '.'; my $from; if($host =~ /$domain/) { # hostname() may return a string like foo.bar.xyz.com and in this case # we want to...
  9. whn

    How to assign bit shift to a variable?

    Thank you, prex1!
  10. whn

    How to assign bit shift to a variable?

    I know this line works: print "OK!! Child($$, $pid) $res ended with ", $? >> 8; print "\n"; But how do I assign the line above into a variable? e.g. $logMsg .= "OK!! Child($$, $pid) $res ended with ", $? >> 8; $logMsg .= "\n"; While compiling it, I got this: Useless use of right bitshift...
  11. whn

    A simple code runs at cmdline, but not in cron job

    I got the solution. I need to set up two ENVs to make cron job run. Basically calling setEnv() before invoke gwsh. My sample code is listed below: sub setEnv { my $sshPid = getSshPid(user=>$ENV{LOGNAME}, psName=>'ssh-agent'); my $sshAuthSock = getSshAuthSock(sshPid=>$sshPid); my %newEnvs =...
  12. whn

    A simple code runs at cmdline, but not in cron job

    In addition, while the code is executed at cmd prompt, following three variables are the same as my own login ID: $ENV{ LOGNAME }, getpwuid( $< ), & $ENV{ USER }. However, while it's executed by the cron job, then $ENV{ USER } is undefined. But both $ENV{ LOGNAME } and getpwuid( $< ) are still...
  13. whn

    A simple code runs at cmdline, but not in cron job

    A simple code just like this: my $cmd = "gwsh root\@$ip \"uname -r\""; my $ret = `$cmd`; When I ran the code at cmd prompt, it's fine. But when it's run in a cron job, $cmd returns nothing. What did I miss here? Many thanks.
  14. whn

    A very simple script does not work

    Hi Chris, Thanks for your input. Tcpdump can send lots of messages through stderr, even if it's not an error at all. That's why I am using 2>/dev/null. In addition, tcpdump cannot exit out by itself. In a script, you can either run it in a child process or in background. Thanks agian.
  15. whn

    A very simple script does not work

    Thank you, Feherke, for your help. I found the solution. All I did was to let it sleep for one second after tcpdump. The '-n' switch does not make the difference, though. But, again, thank you. It's still good to know the '-n' switch.
  16. whn

    A very simple script does not work

    Hi Experts, I have a very simple script listed below: #! /usr/bin/perl my $cmd = "ssh root\@198.18.154.133 \"/a/sbin/tcpdump -v -n -i eth0 port 11640 -w /tmp/mytcpdump.pcap 2>/dev/null\" 2>/dev/null &"; system($cmd); my $cmd2 = "/usr/bin/ssh root\@198.18.154.130 \"cd /tmp; ./go_load...
  17. whn

    Questions about Getopt::Long

    Thank you, rharsh. Your solution works very well. Now, how to solve the problem below: Sample Code: #!/usr/bin/perl use strict; use warnings; use Getopt::Long qw(:config no_auto_abbrev); my ($email, $debug); GetOptions( "d" => \$debug, "e=s" => \$email, ) || die; if($email) { print...
  18. whn

    Failed in installing XML::LibXML

    I am having difficulties in installing XML::LibXML. Below is my system: % cat /etc/issue Ubuntu 14.04.2 LTS \n \l % perl -v This is perl 5, version 18, subversion 2 (v5.18.2) built for x86_64-linux-gnu-thread-multi (with 41 registered patches, see perl -V for more detail) I have...
  19. whn

    Questions about Getopt::Long

    To rharsh, Thank you for pointing out the perldoc. I just read it: But when I set the environment in the code, I don't see the difference: $ENV{POSIXLY_CORRECT} = 1; Am I setting the $ENV{POSIXLY_CORRECT} correctly syntax-wise? OMG, I feel so retarded. #!/usr/bin/perl use strict; use...
  20. whn

    Please help me to understand how Dumper() works.

    Thank you so much, 1DMF, for your detailed explanation. I understand the difference now.

Part and Inventory Search

Back
Top