LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-14-2013, 01:40 PM   #1
lwang3rock
LQ Newbie
 
Registered: Nov 2012
Posts: 20

Rep: Reputation: Disabled
How to give an answer when invoking a command remotely through ssh


Hi,
I am doing
Code:
ssh ipbx@192.84.19.33 'bash -s' ~/unzip test.zip
and it was expecting me to answer [A]ll,[Y]es,[N]o...because there was unzipped before.
How do I give it answer remotely?
I tried
Y|ssh ipbx@192.84.19.33 'bash -s' ~/unzip test.zip
but it didn't work.

Thanks,
Lei
 
Old 02-14-2013, 01:54 PM   #2
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,258

Rep: Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947
leave off the 'bash -s' and just run it normally

Code:
ssh user@IP ~/unzip test.zip
 
Old 02-14-2013, 03:08 PM   #3
lwang3rock
LQ Newbie
 
Registered: Nov 2012
Posts: 20

Original Poster
Rep: Reputation: Disabled
I was able to invoke the command remotely. the problem I am trying to solve is how to give an answer remotely.
 
Old 02-14-2013, 03:14 PM   #4
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,258

Rep: Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947
It will be an interactive shell until the unzip command exits. I'm not sure what the problem is that you're facing.

Code:
[user@comp2 ~]$ cat ~/bin/testscript

echo "type something"
read ans
echo "this is what you typed: $ans"
echo ""
echo "Done"

[user@comp2 ~]$
Code:
[user@comp1 ~]$ ssh user@comp2 ~/bin/testscript
type something
this is a string
this is what you typed: this is a string

Done
[user@comp1 ~]$

Last edited by suicidaleggroll; 02-14-2013 at 03:17 PM.
 
Old 02-14-2013, 07:18 PM   #5
lwang3rock
LQ Newbie
 
Registered: Nov 2012
Posts: 20

Original Poster
Rep: Reputation: Disabled
after I remove 'bash -s', it is interactive, and I was able to give a choice.
ssh ipbx@192.84.19.33 ~/unzip test.zip

I think previously I was putting 'unzip' command in a script.
now I put "read ans" in my script after 'unzip' command

ssh ipbx@192.84.19.33 'bash -s' < ~/unzipvo
Archive: /usr/local/ipbx/voapp-13.0.2.zip
replace voapp-13.0.2/bin/axis.sh? [y]es, [n]o, [A]ll, [N]one, [r]ename: new name: replace voapp-13.0.2/bin/axis.sh? [y]es, [n]o, [A]ll, [N]one, [r]ename: NULL
(EOF or read error, treating as "[N]one" ...)

the unzipvo has something like this

#!/bin/bash
cd ~
unzip ~/test.zip
read ans

How do I combine the 'read ans' with 'unzip command'?
 
Old 02-14-2013, 07:43 PM   #6
Habitual
LQ Addict
 
Registered: Jan 2011
Location: Youngstown, Ohio
Distribution: LM17.1/Xfce4.11.8
Posts: 7,185
Blog Entries: 10

Rep: Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981
-o overwrite files WITHOUT prompting ?
 
Old 02-14-2013, 07:58 PM   #7
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,258

Rep: Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947
Quote:
Originally Posted by lwang3rock View Post
after I remove 'bash -s', it is interactive, and I was able to give a choice.
ssh ipbx@192.84.19.33 ~/unzip test.zip

I think previously I was putting 'unzip' command in a script.
now I put "read ans" in my script after 'unzip' command

ssh ipbx@192.84.19.33 'bash -s' < ~/unzipvo
Archive: /usr/local/ipbx/voapp-13.0.2.zip
replace voapp-13.0.2/bin/axis.sh? [y]es, [n]o, [A]ll, [N]one, [r]ename: new name: replace voapp-13.0.2/bin/axis.sh? [y]es, [n]o, [A]ll, [N]one, [r]ename: NULL
(EOF or read error, treating as "[N]one" ...)

the unzipvo has something like this

#!/bin/bash
cd ~
unzip ~/test.zip
read ans

How do I combine the 'read ans' with 'unzip command'?
The "read ans" in my earlier post was just an example to show that the ssh connection is interactive. Why are you using a script at all?

I guess I'm just not clear on what this:
Code:
ssh ipbx@192.84.19.33 unzip ~/test.zip
Is not doing for you.
 
Old 02-15-2013, 12:59 PM   #8
lwang3rock
LQ Newbie
 
Registered: Nov 2012
Posts: 20

Original Poster
Rep: Reputation: Disabled
-o overwrite files WITHOUT prompting will work too.
I was exploring how to do things in different ways.
I didn't figure out how to do it if I put it in the script.
I remember I saw somewhere online it is something like the following
"Y|ssh ipbx@192.84.19.33 'bash -s' < ~/unzipvo" but it didn't work. Maybe I didn't remember correctly.
I am posting it in case somebody knows how to do it that way.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I append to a file remotely using a linux command (via ssh keys) abefroman Programming 2 11-27-2009 10:51 PM
How to prevent others from remotely logging into my pc through ssh command? CPurnima Linux - Newbie 7 11-26-2008 09:10 AM
C++ windows server but linux client app remotely invoking methods linuxmandrake Programming 2 10-12-2008 09:09 PM
from Win XP, remotely execute a command on Linux using ssh lothario Linux - Software 3 06-21-2008 06:59 PM
Invoking a shell script remotely. niks27 Linux - Newbie 1 10-11-2007 08:22 AM


All times are GMT -5. The time now is 02:31 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration