Solved

Linux, script to putty in

Posted on 2013-12-17
3
242 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Currently, there is not an RPM package available under the RHEL/Fedora/CentOS distributions that gives you a quick and easy way to allow PHP to interface with Oracle. As a result, I have included a set of instructions on how to do this with minimal …
Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
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…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

744 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

11 Experts available now in Live!

Get 1:1 Help Now