How to run the script with out any interruption ?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to run the script with out any interruption ?
# 1  
Old 01-12-2012
How to run the script with out any interruption ?

Hi ,

Loggin to another host using the below command in my shell script
Code:
 
ssh-keygen > /dev/null
ssh-copy-id -i ~/.ssh/id_rsa.pub

My problem is , the second commmand expecting a user input

Eg :

Press Enter for below three questions and issue your password
Enter file in which to save the key (/home/v45542/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):

Every time I have to press enter for these three question whenever I run the script. I want to skip or it should automatically skip this three questions. Please help in this . I am new to this thread

Moderator's Comments:
Mod Comment Please use next time code tags

Last edited by vbe; 01-12-2012 at 05:42 AM..
# 2  
Old 01-12-2012
Bug

You can use Expect, which is very popular in many system.
I google here some stuff:

oreilly.com/catalog/expect/chapter/ch03.html
bash.cyberciti.biz/security/expect-ssh-login-script
code.seanodonnell.com/?id=21
# 3  
Old 01-12-2012
Thanks a lot for the reply. But I am not sure how to implement this with my requirment. Can yopu help me out ?
# 4  
Old 01-12-2012
Hi,
you can pass Enter like this too
Code:
echo |sh script.sh

a simple echo will return new line

thanks,
venkat

Last edited by Franklin52; 01-13-2012 at 04:35 AM.. Reason: Please use code tags for code and data samples, thank you
# 5  
Old 01-12-2012
Code:
if [ $# != 3 ]
then
        echo "Syntax wrong : Correct Syntax is ./wrapper.sh <client_name> <start_time> <end_time>"
        exit
fi
start_time=$2
end_time=$3
yy=`echo $2 | cut -c 3-4`
mm=`echo $2 | cut -c 6-7`
dd=`echo $2 | cut -c 9-10`
start_hr=`echo $2 | cut -c 12-13`
end_hr=`echo $3 | cut -c 12-13`
var=`cat $1`
IFSsave="$IFS"
IFS=,
vars=($var)
IFS="$IFSsave"
quote_startdate="\"$2\""
quote_enddate="\"$3\""
echo "Press Enter for below three questions and issue your password"
ssh-keygen > /dev/null
ssh-copy-id -i ~/.ssh/id_rsa.pub ${vars[0]} > /dev/null 2&>1
for (( i=0; i < ${#vars[@]}; i++ ))
do
ssh ${vars[i]}
#"echo Executing script for host; hostname; cd /auto/users-03/p531354/martrefresh; echo Current Directory; pwd ; *running ruby script here* "
done
rm ~/.ssh/authorized_keys ~/.ssh/id_rsa ~/.ssh/id_rsa.pub


Hi ,
Please find the above code.. echo | sh wrapper.sh param... Not working here
vars is nothing but the hostname

Last edited by Franklin52; 01-12-2012 at 06:50 AM.. Reason: Please use code tags for code and data samples, thank you
# 6  
Old 01-12-2012
hi,
i think this is the place where you need to keep echo /pass enter
Code:
echo |ssh-keygen > /dev/null
echo |ssh-copy-id -i ~/.ssh/id_rsa.pub ${vars[0]} > /dev/null 2&>1
for (( i=0; i < ${#vars[@]}; i++ ))
do
echo |ssh ${vars[i]}
#"echo Executing script for host; hostname; cd /auto/users-03/p531354/martrefresh; echo Current Directory; pwd ; *running ruby script here* "
done

please point me where you need to pass enter in the script portion

thanks,
venkat

Last edited by Franklin52; 01-12-2012 at 06:51 AM.. Reason: Please use code tags for code and data samples, thank you
# 7  
Old 01-12-2012
This is the line :
Code:
ssh-copy-id -i ~/.ssh/id_rsa.pub ${vars[0]} > /dev/null 2&>1

Its working for one time enter . But here i need to pass three enter ..

How to do it
Please help me out

Last edited by Franklin52; 01-13-2012 at 04:35 AM.. Reason: Please use code tags for code and data samples, thank you
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script run in a case statement call to run a php file, also Perl

Linux System having all Perl, Python, PHP (and Ruby) installed From a Shell script, can call a Perl, Python, PHP (or Ruby ?) file eg eg a Shell script run in a case statement call to run a php file, also Perl or/and Python file??? Like #!/usr/bin/bash .... .... case $INPUT_STRING... (1 Reply)
Discussion started by: hoyanet
1 Replies

2. Programming

Simple capturing of keyboard input without interruption

I would like to make a function or command that checks for keyboard input without interrupting the program and exits the program when a key is pressed (perhaps the 'q' key). The program below monitors and prints/executes commands upon a change in primary (mouse selection) or clipboard buffer. If... (4 Replies)
Discussion started by: bedtime
4 Replies

3. Shell Programming and Scripting

Script fails to run properly when run from CRONTAB

Hello all, I'm trying to write a script to gather and send data and it works just fine at the bash command line, but when executing from CRON, it does not run properly. My scripting skills are pretty limited and there's probably a better way, but as I said it works at the command line, but... (12 Replies)
Discussion started by: rusman
12 Replies

4. AIX

ssh interruption after aix os upgrade

Hi Through nimadm (alt_disk_install) we done aix os upgrade in 3 lpars from aix 5.3 to aix 6.1. upgrade was successful. After the upgrade users complained on their ssh keys. Does upgrading aix version affects the user's ssh keys ? If so please suggest on options to correct them. (1 Reply)
Discussion started by: newtoaixos
1 Replies

5. Shell Programming and Scripting

how to run an already made script run against a list of ip addresses solaris 8 question

how to run an already developed script run against a list of ip addresses solaris 8 question. the script goes away and check traffic information, for example check_GE-VLANStats-P3 1.1.1.1 and returns the results ok. how do I run this against an ip list? i.e a list of 30 ip addresses (26 Replies)
Discussion started by: llcooljatt
26 Replies

6. Shell Programming and Scripting

ssh connection through shell script with no interruption

Hi all, I need ssh in shell script. My requirement is: - Take user_name and password from user (in PHP) - Pass this to shell script which will: - connect via ssh - Run sql query - Pass the results back in PHP - Put the results to website. I know PHP has libraries for ssh and ftp, but... (3 Replies)
Discussion started by: shekhar2010us
3 Replies

7. UNIX and Linux Applications

Apache+Perl: interruption of STDIN

Hello dear community! I have faced with a trouble which I trying to solve for a long time. I have service of video streaming. And I have web and video roles for servers. Video servers upload video using SWFUpload and then stream it. Issue became during uploading of video. In random time... (3 Replies)
Discussion started by: sevmax
3 Replies

8. Red Hat

util-linux upgrade with interruption?

Hi All, I have util-linux upgrade that I need to do on redhat 4 ent. Does this going to interruption with the operation of the OS or application? Or this will be straight forward upgrade that will not make a harm or downtime of the OS. Thank you for any comments you may add. (3 Replies)
Discussion started by: itik
3 Replies

9. Programming

Wireless C program conncection interruption problem

Dear Gurus My company has a wireless handheld C program as text-mode workstations in remote sites. We suspected that the program get interrupted sometimes because of out-of-wireless access and hence resulted in db record locking and other issue. It did trouble us a lot. Is it possible to use... (2 Replies)
Discussion started by: charles_chu
2 Replies
Login or Register to Ask a Question