I'm using PuTTY to remotely log onto my school's host. Upon logging in, we are required to do these steps:
I will be logging into this host a lot over the course of this semester and I was hoping to create a script that would eliminate the redundancy of the above steps. Ignoring the obvious security oversights of having my password in the script, how would I achieve this? I have zero experience with scripting, so your feedback is greatly appreciated. Thanks!
Edit: I played around with the command-line options for Putty and I was able to bypass steps 1-2 using:
putty -load "host" -l username -pw password
I've also created a shell file that looks like so:
#!/bin/bash
add oracle10g
sqlplus username password
When I try to add this option to the command-line using the -m option, it looks like PuTTY logs into the host and then immediately exits. Is there a way to keep my session open after running the shell file or am I using the -m option wrongly? Here is a link to a PuTTY guide that I have been following: http://the.earth.li/~sgtatham/putty/0.60/htmldoc/Chapter3.html.
Here is the total command that I am trying to run from the command-line:
putty -load "host" -l username -pw password -m c:\test.sh
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:
putty.bat
. This opens PuTTY and logs me into the host.tcsh sql
. This adds the oracle tool to my host, and logs me into the sql database.