Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
added 49 characters in body
Source Link
smokinguns
  • 103
  • 1
  • 3

All,
EDIT
I want to execute a unix statement in Expect script and get an output without having to include the interact statement.The unix statement outputs rsize value for a process. I haven't programmed in Expect before. This is my code:

 #!/usr/bin/expect set some_host "some host" set Mycmd "top -l 1 -stats pid,rsize,command | grep Process_Name| awk '{print \$2};'" spawn telnet localhost $some_host expect "login:" send "myDevice\r" expect "Password:" send "$password\r" expect "\$" send "$Mycmd\r"  interact 

WhenIf I execute thisdon't include the interact statement, I don't get any output. What's the correct syntax to execute the unix statement in Expect ? How do I get this to work so that I get the correct rsize value as the output?

All,
I want to execute a unix statement in Expect script.The unix statement outputs rsize value for a process. I haven't programmed in Expect before. This is my code:

 #!/usr/bin/expect set some_host "some host" set Mycmd "top -l 1 -stats pid,rsize,command | grep Process_Name| awk '{print \$2};'" spawn telnet localhost $some_host expect "login:" send "myDevice\r" expect "Password:" send "$password\r" expect "\$" send "$Mycmd\r" 

When I execute this, I don't get any output. What's the correct syntax to execute the unix statement in Expect ? How do I get this to work so that I get the correct rsize value as the output?

All,
EDIT
I want to execute a unix statement in Expect script and get an output without having to include the interact statement.The unix statement outputs rsize value for a process. I haven't programmed in Expect before. This is my code:

 #!/usr/bin/expect set some_host "some host" set Mycmd "top -l 1 -stats pid,rsize,command | grep Process_Name| awk '{print \$2};'" spawn telnet localhost $some_host expect "login:" send "myDevice\r" expect "Password:" send "$password\r" expect "\$" send "$Mycmd\r"  interact 

If I don't include the interact statement, I don't get any output. How do I get this to work so that I get the correct rsize value as the output?

Source Link
smokinguns
  • 103
  • 1
  • 3

Get unix 'top' command output from Expect script

All,
I want to execute a unix statement in Expect script.The unix statement outputs rsize value for a process. I haven't programmed in Expect before. This is my code:

 #!/usr/bin/expect set some_host "some host" set Mycmd "top -l 1 -stats pid,rsize,command | grep Process_Name| awk '{print \$2};'" spawn telnet localhost $some_host expect "login:" send "myDevice\r" expect "Password:" send "$password\r" expect "\$" send "$Mycmd\r" 

When I execute this, I don't get any output. What's the correct syntax to execute the unix statement in Expect ? How do I get this to work so that I get the correct rsize value as the output?