TCLUG Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [TCLUG:2010] automatic telnet etc



In a message dated 10/29/98, 4:57:57 PM, tclug-list@listserv.real-time.com
writes:
<<Well, I've got some things working. My .procmail looks like this: (Your
other suggestion didn't work because procmail had problems with a "(" in
the *^Received line, so I just did this and used sed) But this is
fundamentally the same.>>
--
I think you can replace the "(" with a "." which says match any character.
Or try escaping it with a backslash in .procmailrc.

This way you could avoid having the multiple ips from the grep in the
getip.txt file.
Or use "tail -1" at the end of the grep command:

grep "Received: from hearing" ~/mail/hearing | tail -1  >~/getip.txt

This will get you only the last line from the multiple lines you have.

Here is a nasty way to automate your telnet process, I am not too sure of its 
success but play with it:

( echo open $address; echo $login; echo $passwd; 
  echo nohup xterm -display $localhost;  
  echo exit
 ) | telnet

Basically you pipe all the login info and commands you need into telnet.
For a slow connection you can try putting "sleeps" in between the "echo"
commands or else telnet might get confused if it gets the login and the
password before
it has even connected.

Where $address: is the address of the machine you telnet to
            $localhost is the address of your local machine.
            login, passwd are your userid and passwords

You will not be able to do anything on the window where you run telnet. i.e.
if you replace the "xterm" with a "vi" command in line 2 it will mess up.

In fact a better way would be to use something like  "chat"  where you send a
command only when you receive a response from the telnet command. It should be
easy to whip up a simple script to do it, so that you donot have to use sleeps
to wait
for the server to respond.

Let me know if you find this useful. :)
---