Using conditional statements inside ‘expect’

Have to recomment the Exploring Expect book for all expect programmers — invaluable. I’ve rewritten your code: (untested) proc login {user pass} { expect “login:” send “$user\r” expect “password:” send “$pass\r” } set username spongebob set passwords {squarepants rhombuspants} set index 0 spawn telnet 192.168.40.100 login $username [lindex $passwords $index] expect { “login incorrect” { … Read more

Python – inheriting from old-style classes

You need to call the constructor like this: telnetlib.Telnet.__init__(self, host, port, timeout) You need to add the explicit self since telnet.Telnet.__init__ is not a bound method but rather an unbound method, i.e. witout an instance assigned. So when calling it you need to pass the instance explicitely. >>> Test.__init__ <unbound method Test.__init__> >>> Test().__init__ <bound … Read more

What does “\r” do in the following script?

The ‘\r’ character is the carriage return, and the carriage return-newline pair is both needed for newline in a network virtual terminal session. From the old telnet specification (RFC 854) (page 11): The sequence “CR LF”, as defined, will cause the NVT to be positioned at the left margin of the next print line (as … Read more

Creating a script for a Telnet session?

I’ve used various methods for scripting telnet sessions under Unix, but the simplest one is probably a sequence of echo and sleep commands, with their output piped into telnet. Piping the output into another command is also a possibility. Silly example (echo password; echo “show ip route”; sleep 1; echo “quit” ) | telnet myrouter … Read more

HTTP keep-alive timeout

The client cannot specify the timeout, it is the server configuration that determines the maximum timeout value. The extra Keep-Alive header can inform the client how long the server is willing to keep the connection open (timeout=N value) and how many requests you can do over the same connection (max=M) before the server will force … Read more

Connecting to smtp.gmail.com via command line

Using Linux or OSx, do what Sorin recommended but use port 465 instead. 25 is the generic SMTP port, but not what GMail uses. Also, I don’t believe you want to use -starttls smtp openssl s_client -connect smtp.gmail.com:465 You should get lots of information on the SSL session and the response: 220 mx.google.com … Type … Read more

How to send an HTTP request using Telnet [closed]

You could do telnet stackoverflow.com 80 And then paste GET /questions HTTP/1.0 Host: stackoverflow.com # add the 2 empty lines above but not this one Here is a transcript $ telnet stackoverflow.com 80 Trying 151.101.65.69… Connected to stackoverflow.com. Escape character is ‘^]’. GET /questions HTTP/1.0 Host: stackoverflow.com HTTP/1.1 200 OK Content-Type: text/html; charset=utf-8 …

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)