Solved

Linux, script to putty in

Posted on 2013-12-17
3
245 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to install Ubuntu 16 in DELL venue 8 pro 20 274
Penetration Testing home based work 3 91
awk file 6 77
list of sudo access for date range 5 28
I am a long time windows user and for me it is normal to have spaces in directory and file names. Changing to Linux I found myself frustrated when I moved my windows data over to my new Linux computer. The problem occurs when at the command line.…
Using 'screen' for session sharing, The Simple Edition Step 1: user starts session with command: screen Step 2: other user (logged in with same user account) connects with command: screen -x Done. Both users are connected to the same CLI sessio…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

789 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