Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Linux, script to putty in

Posted on 2013-12-17
3
Medium Priority
?
253 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

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

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…
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
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.
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.
Suggested Courses

636 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