PuTTY scripting to log onto host

前端 未结 8 923
被撕碎了的回忆
被撕碎了的回忆 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:24

    Figured this out with the help of a friend. The -m PuTTY option will end your session immediately after it executes the shell file. What I've done instead is I've created a batch script called putty.bat with these contents on my Windows machine:

    @echo off
    putty -load "host" -l username -pw password
    

    This logs me in remotely to the Linux host. On the host side, I created a shell file called sql with these contents:

    #!/bin/tcsh
    
    add oracle10g
    sqlplus username password
    

    My host's Linux build used tcsh. Other Linux builds might use bash, so simply replace tcsh with bash and you should be fine.

    To summarize, automating these steps are now done in two easy steps:

    1. Double-click putty.bat. This opens PuTTY and logs me into the host.
    2. Run command tcsh sql. This adds the oracle tool to my host, and logs me into the sql database.

提交回复
热议问题