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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Spawn/bin/bash

Status
Not open for further replies.

ginesgb

Technical User
Sep 15, 2016
3
ES
Hi all, I have written several shell scritp with tcl/tk and I run it on the machine with the user group, when I give it to another user with different machine or from another IP it gives error.

Spawn/bin/bash

But if I run it from my machine where I wrote it, it runs correctly.

The header is so definite.

#! / Usr/bin/expect -f
#

Can you tell me that I have not added or am missing so that it can run from any pc and any user?
Greetings and thank you
 
maybe expect is not installed on the other machines ?
 
Hi, I have reviewed the code and now it can run, but I have several problems now.

Code:
[lab@stadis]$ cat TM_ping.exp
#!/usr/bin/expect -f

set timeout -1
spawn $env(SHELL)
match_max 100000
send -- "telnet XXX.XXX.XXX.XXX"
expect -exact "telnet XXX.XXX.XXX.XXX"
send -- "\r"
expect -exact "\r
username: "
send -- "lab"
expect -exact "lab"
send -- "\r"
expect -exact "\r
password: "
send -- "lab\r"
expect -exact "\r
\r
MT>"
send -- "enable\r"
expect -exact "enable\r
Password: "
send -- "Megapassword!\r"
expect -exact "\r
MT#"
set output [open "/usr/local/stadis/TM_ping.exp" "a+"]
sleep 2
send -- "ping\r"
expect -exact "ping\r
Protocol \[ip\]: "
send -- "\r"
expect -exact "\r
Target IP address: "
send -- "XXX.XXX.XXX.XXX"
expect -exact "XXX.XXX.XXX.XXX"
send -- "\r"
expect -exact "\r
Repeat count \[5\]: "
send -- "10000\r"
expect -exact "10000\r
Datagram size \[100\]: "
send -- "\r"
expect -exact "\r
Timeout in seconds \[2\]: "
send -- "\r"
expect -exact "\r
Extended commands \[n\]: "
send -- "y\r"
expect -exact "y\r
Source address or interface: "
send -- "vlan100"
expect -exact "vlan100"
send -- "\r"
expect -exact "\r
Type of service \[0\]: "
send -- "\r"
expect -exact "\r
Set DF bit in IP header? \[no\]: "
send -- "\r"
expect -exact "\r
Validate reply data? \[no\]: "
send -- "\r"
expect -exact "\r
Data pattern \[0xABCD\]: "
send -- "\r"
expect -exact "\r
Loose, Strict, Record, Timestamp, Verbose\[none\]: "
send -- "\r"
expect -exact "\r
Sweep range of sizes \[n\]: "
send -- "\r"
expect "*#"
set outcome $expect_out(buffer)
send "\r"
puts $output $outcome
incr i
close $output
send -- "\r"
expect -exact "\r
MT#"
send -- "exit\r"
expect -exact "exit\r
send -- "exit\r"
expect -exact "exit\r
send -- "\r"
send -- ""
expect eof
[lab@stadis]$

1.- It does not finish the files well when it is executed.
2.- I do not understand why when I throw it with the crontab it gives an error and does not execute it

What steps are not performed correctly?

Greetings and thank you
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top