Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
remote ssh commands?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
jpc82
Guru
Guru


Joined: 09 Mar 2003
Posts: 326

PostPosted: Fri Sep 26, 2003 12:25 pm    Post subject: remote ssh commands? Reply with quote

I'm trying to write a tcl script for my current co-op job and I've almost got it, but I've run into a problem.

What my script will do is redeploy a WebSphere Application. My problem is that the once I remove the application from the server I need to cleanup the files that are still on the node, which is a different computer.

Is there anyway to execute my cleanup script on a remote computer from inside the tcl script?

Note: the only access I have to the remote computer is ssh
Back to top
View user's profile Send private message
Antonio
n00b
n00b


Joined: 07 Mar 2003
Posts: 35
Location: Manaus, AM - Brasil

PostPosted: Fri Sep 26, 2003 1:49 pm    Post subject: Reply with quote

you can pass a command to the ssh program (i am not sure about the syntax):
ssh root@192.168.1.1 delete_all_cores

so, the ssh will ask the password and will run the script delete_all_cores at 192.168.1.1

hope it helps,

anTONIo
Back to top
View user's profile Send private message
nephros
Advocate
Advocate


Joined: 07 Feb 2003
Posts: 2139
Location: Graz, Austria (Europe - no kangaroos.)

PostPosted: Fri Sep 26, 2003 1:49 pm    Post subject: Reply with quote

Have you tried this:
Code:
ssh user@host /remote/path/to/script

Yes it is that easy :). If you want it passwordless, you'd have to set up some sort of key-based authentication.

And
wrote:

(956) Tcl Reference Manual: exec

This command treats its arguments as the specification of one or more subprocesses to execute. The arguments take the form of a standard shell pipeline where each arg becomes one word of a command, and each distinct command becomes a subprocess.
If the last arg is ``&'' then the pipeline will be executed in background. In this case the exec command will return a list whose elements are the process identifiers for all of the subprocesses in the pipeline.

_________________
Please put [SOLVED] in your topic if you are a moron.
Back to top
View user's profile Send private message
jpc82
Guru
Guru


Joined: 09 Mar 2003
Posts: 326

PostPosted: Fri Sep 26, 2003 2:16 pm    Post subject: Reply with quote

I was reading the man page and I found out how to add a command to run, like nephros, and Antonio suggested. Now my problem is the password.

I don't see a switch that allows you to place the password in the command line, is there any way of doing this?
Back to top
View user's profile Send private message
jpc82
Guru
Guru


Joined: 09 Mar 2003
Posts: 326

PostPosted: Fri Sep 26, 2003 2:22 pm    Post subject: Reply with quote

I'm wondering if I could place the password in a variable and then redirect stdin to the variable, but I can't get it to work.

this is what I tried

ssh 127.0.0.1 "ls -l" < test

and test is a file that has one line, which is the password
Back to top
View user's profile Send private message
Sieg
Tux's lil' helper
Tux's lil' helper


Joined: 07 Oct 2002
Posts: 87

PostPosted: Fri Sep 26, 2003 2:25 pm    Post subject: Reply with quote

as nephros said, for that you'll have to use key authentication, which does not require many changes with DSA.

http://www-106.ibm.com/developerworks/linux/library/l-keyc.html

Above is a pretty good explanation on the subject.

Hope this helps
Back to top
View user's profile Send private message
jpc82
Guru
Guru


Joined: 09 Mar 2003
Posts: 326

PostPosted: Fri Sep 26, 2003 2:31 pm    Post subject: Reply with quote

I really doubt I will be able to do that since once I'm done with this srcipt and I've tested it on our acceptence environment, they will be putting it on thier production environment. And they don't make any security changes to thier production environment unless there is very good reason to do so.

And the process to get a change made is a very slow one.

Any other way to get around this problem would be great.

Thanks in advance
Back to top
View user's profile Send private message
jpc82
Guru
Guru


Joined: 09 Mar 2003
Posts: 326

PostPosted: Fri Sep 26, 2003 3:21 pm    Post subject: Reply with quote

I have one more thing to add.

I'm ok with the script prompting the user for a password. My only problem is that I will need to run multiple scripts remotly at differnt time, and I don't want to have to prompt the user for the same password 3-4 times.

I know how to prompt the user for the password and then capture it in a variable using tcl, however I just can't figure out how to use that variable to input the password to the ssh command
Back to top
View user's profile Send private message
CMI
Apprentice
Apprentice


Joined: 19 Aug 2003
Posts: 205

PostPosted: Sat Sep 27, 2003 7:35 am    Post subject: Reply with quote

Can you SSH in, echo the contents of a local file through SSH into a file via piping "> file", execute, delete, pipe, execute, delete...

That way you only use one connection for as many different scripts and executions as you want.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum