|
| Hi all,
Ive created a script whitch executes some commands on rome systems.
This worked well until I used a long command.
This is a part of the script:
$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 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.
But somehow the perl Expect doesnt see the command because it will timeout.
The command it executes is:
cat /etc/testfile | awk '{ FS = ":" ; print $1 }' | grep -v '^[#*]' | grep -v '^$'
The output I get back (what actually is in $data) is:
":" ; print $1 }' | grep -v '^[#*]' | grep -v '^$' <
Command output 1
(... SNIP ...)
Command output xx
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...
I tried some stuff.. to escape the $ and # and stuff, use substr but nothing seems to work, does someone know a solution?
Thanks in advance,
DiffZ |
|