PuTTY scripting to log onto host

前端 未结 8 882
被撕碎了的回忆
被撕碎了的回忆 2021-02-14 11:53

I\'m using PuTTY to remotely log onto my school\'s host. Upon logging in, we are required to do these steps:

  1. enter username
  2. enter password
  3. comman
8条回答
  •  礼貌的吻别
    2021-02-14 12:27

    When you use the -m option putty does not allocate a tty, it runs the command and quits. If you want to run an interactive script (such as a sql client), you need to tell it to allocate a tty with -t, see 3.8.3.12 -t and -T: control pseudo-terminal allocation. You'll avoid keeping a script on the server, as well as having to invoke it once you're connected.

    Here's what I'm using to connect to mysql from a batch file:

    #mysql.bat start putty -t -load "sessionname" -l username -pw password -m c:\mysql.sh

    #mysql.sh mysql -h localhost -u username --password="foo" mydb

    https://superuser.com/questions/587629/putty-run-a-remote-command-after-login-keep-the-shell-running

提交回复
热议问题