Solved

Linux, script to putty in

Posted on 2013-12-17
3
243 Views
Last Modified: 2013-12-17
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
Comment
Question by:Los Angeles1
  • 2
3 Comments
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 39724263
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
 

Author Comment

by:Los Angeles1
ID: 39724363
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
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 500 total points
ID: 39724435
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Daily system administration tasks often require administrators to connect remote systems. But allowing these remote systems to accept passwords makes these systems vulnerable to the risk of brute-force password guessing attacks. Furthermore there ar…
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now