DiffZ has asked for the wisdom of the Perl Monks concerning the following question:
The problem is that when I execute a long command (more than one line) the terminal screws it up so i only see the last part of the command. To fix this I use substr to match only the last 20 chars of the command.$connection->send("$cmd\r"); if(length($cmd) > "25") { $cmd = substr($cmd, -20); } $connection->expect(8, '$cmd'); $connection->expect($timeout, $prompt); $data = $connection->exp_before(); print "Command DATA: \n$data\n";
The output I get back (what actually is in $data) is:cat /etc/testfile | awk '{ FS = ":" ; print $1 }' | grep -v '^[#*]' | +grep -v '^$'
That first line contains a part of the command, and I dont want to see that line. I cant just cut of the first line because with simple commands it works fine...":" ; print $1 }' | grep -v '^[#*]' | grep -v '^$' < Command output 1 (... SNIP ...)Command output xx
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Problem with perl expect
by jbrugger (Parson) on Feb 15, 2005 at 09:14 UTC | |
by DiffZ (Initiate) on Feb 15, 2005 at 09:45 UTC |