Solved

ksh secure copy (scp) - catch password prompt

Posted on 2007-11-15
3
2,038 Views
Last Modified: 2013-12-26
I'm writing a korn shell script that includes automatic secure copying of a file to several servers.  If the current user is not configured for scp on the server, it will prompt for a password.  I'd like to catch this prompt and end the scp call if the prompt occurs.  Any help would be greatly appreciated!
0
Comment
Question by:trinity12583
3 Comments
 
LVL 40

Accepted Solution

by:
omarfarid earned 500 total points
ID: 20290699
Hi,

For this, use expect. The links below are useful in learning expect. You may download expect from the home page if not already available on your m/c.

http://expect.nist.gov/
http://www.csc.calpoly.edu/~dbutler/tutorials/winter96/expect/tutorial.html
http://www.linuxjournal.com/article/3065
http://expect.nist.gov/example/autoexpect.man.html


0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 20290954
i.g. ssh-keygen is the way to go
If that is not possible then expect will be best.
0
 

Author Closing Comment

by:trinity12583
ID: 31409353
I was able to use the resources you gave to get a basic understanding ot Tcl and Expect and wrote a small script to accomplish what I needed in less than an hour!  Thanks so much!  :-)
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need to roll back kernel via script 4 86
How to run git alias with shell other than sh 17 114
Message not shown 5 67
Expiration and Locking of Unix/Solaris OS Accounts 7 51
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.:
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

828 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