Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

telnet scripts?

Options
  • 17-05-2004 4:56pm
    #1
    Closed Accounts Posts: 28


    i wonder if someone can help me:

    if i wanted to automatically run a command line in ftp, i could put that line in a txt file like script.txt and then write a batch file something like: ftp -s:script.txt netsoc.ucd.ie

    the question is, can i do something similar with telnet? ie, open it, run a script, close it.


Comments

  • Registered Users Posts: 1,268 ✭✭✭hostyle




  • Registered Users Posts: 1,186 ✭✭✭davej


    You can run commands on another box using rsh or ssh.

    man rsh
    man ssh

    Using a telnet perl module is total overkill for what you appear to be after....

    davej


  • Closed Accounts Posts: 53 ✭✭dmd


    You have a few choices here, two come to mind. One would be using scp or ssh with a blank key. This should be done on a client, you shouldn't have these keys on a server. This little piece goes into doing it this way. This can basically be used to do ssh or scp, so like telnet or ftp.

    The other way would be using a scripting language like expect to do it, it was designed for this type of thing also. You could use this with scp or ssh also, just to do $x commands and exit. Here's a link to a short tutorial on expect.


  • Registered Users Posts: 3,886 ✭✭✭cgarvey


    Originally posted by dmd
    You have a few choices here, two come to mind. One would be using scp or ssh with a blank key. This should be done on a client, you shouldn't have these keys on a server. This little piece goes into doing it this way. This can basically be used to do ssh or scp, so like telnet or ftp.

    Blank key? How would a blank key be useful? Furthermore, how do you go about creating one, as I couldn't see it in the URL you posted. Do you mean blank password on the private key or something?

    .cg


  • Closed Accounts Posts: 53 ✭✭dmd


    run ssh-keygen -t dsa , when prompted for the directory to save to, just hit enter, once prompted for the passphrase also hit enter and do not enter any passphase, you should then get your keys in the .ssh directory of the users home directory. I would advise you to run chmod 700 on the users home directory, so no other users on the system can see files contained in there.

    So now you can run

    ssh whatever.host.com mycommand

    and pipe to output to a logfile and mail it to yourself or $whatever, you could also put this on crontab to run nightly or $whenever.


  • Advertisement
  • Registered Users Posts: 3,886 ✭✭✭cgarvey


    Originally posted by dmd
    So now you can run

    ssh whatever.host.com mycommand

    and pipe to output to a logfile and mail it to yourself or $whatever, you could also put this on crontab to run nightly or $whenever.

    Got it, and that's what I do normally, but I was confused by your "blank key". The key is far from blank in this case. That's all.

    A variation on this is to limit what the user can do (for example, limit them to CVS usage only), which is very handy.

    .cg


Advertisement