Execute unix command from perl running on windows

Reply

Join Date: Jan 2007
Posts: 2
Reputation: alex_wil is an unknown quantity at this point 
Solved Threads: 0
alex_wil alex_wil is offline Offline
Newbie Poster

Execute unix command from perl running on windows

 
0
  #1
Jan 12th, 2007
Hi friends,

I am using Perl Tk for a GUI application. It uses a telnet part wherin I need to login to a unix machine, execute a command and process the result.

The code is as follows :

my $result = $t->cmd(("grep - $filename.txt~ | wc -l | awk '{print $1}'"));

I am basically searching for '-" in the $filename.txt~.

The problem i am having is, the result always comes as 1 .. even thou the file does not contain any '-' symbol.
The command runs fine when used directly on unix.

Would appreciate if any one of you can help me out.

Regards,
Alex
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 898
Reputation: KevinADC has a spectacular aura about KevinADC has a spectacular aura about 
Solved Threads: 67
KevinADC's Avatar
KevinADC KevinADC is offline Offline
Practically a Posting Shark

Re: Execute unix command from perl running on windows

 
0
  #2
Jan 12th, 2007
maybe you need to use an array instead of a scalar for capturing the reults:

my @result = $t->cmd(("grep - $filename.txt~ | wc -l | awk '{print $1}'"));
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 2
Reputation: alex_wil is an unknown quantity at this point 
Solved Threads: 0
alex_wil alex_wil is offline Offline
Newbie Poster

Re: Execute unix command from perl running on windows

 
0
  #3
Jan 15th, 2007
Hi Kevin,

thanks for your reply. I did try as per what you told me too. but I still get no result.

Regards,
Alex


Originally Posted by KevinADC View Post
maybe you need to use an array instead of a scalar for capturing the reults:

my @result = $t->cmd(("grep - $filename.txt~ | wc -l | awk '{print $1}'"));
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 6
Reputation: mandible is an unknown quantity at this point 
Solved Threads: 0
mandible mandible is offline Offline
Newbie Poster

Re: Execute unix command from perl running on windows

 
0
  #4
Jan 31st, 2007
I'm very new to perl but you can try this
my @result = `grep - $filename.txt~ | wc -l | awk '{print $1}'"`;
that might work for you,
using the backtick which is the character under the tilda will run a system command and return the results back to your program.

Sorry if this doesn't work I"m very new at Perl.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC