[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 254
  • Last Modified:

Linux, script to putty in

I am using RHEL 6.4

I need a script that will putty into another machine with a username and password, and after that happens, perform a vi, and then exit the putty session

Could someone please post an example of how to do this ?

Thanks
0
Los Angeles1
Asked:
Los Angeles1
  • 2
1 Solution
 
woolmilkporcCommented:
Hi,

PuTTY has a companion batch program called "plink" which is meant just for purposes like yours.

Using plink you can do

plink -t user@host -pw password "/path/to/remote/command"

plink is here:

http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html

Download link:

http://the.earth.li/~sgtatham/putty/latest/x86/plink.exe

But why in the world would you want to run vi (an interactive editor)?

There are always other means to manipulate files in batch, vi is never needed.
0
 
Los Angeles1Author Commented:
Three points:  

1>  I am sorry, I meant to say 'ls -la' instead of 'vi'

2>  I meant to only ask how to do a "ls -la" because I want to eventually copy files to many different linux machines, and also remotely start processes.  I wanted to start with a 'ls-la'

3> Unfortunately in this environment I am not allowed to import plink.  Could you please post a way to do this from putty ?

Thanks
0
 
woolmilkporcCommented:
You can use a local  file containing the desired commands (e.g. "ls -la")

putty -t user@host -pw password -m local_commands_file

PuTTY's window will close as soon as all commands have finished executing. Best add "read xxx" as the last command, so the shell will wait for you to enter something.
0

Featured Post

Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now