View previous topic :: View next topic |
Author |
Message |
jpc82 Guru
Joined: 09 Mar 2003 Posts: 326
|
Posted: Fri Sep 26, 2003 12:25 pm Post subject: remote ssh commands? |
|
|
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 |
|
|
Antonio n00b
Joined: 07 Mar 2003 Posts: 35 Location: Manaus, AM - Brasil
|
Posted: Fri Sep 26, 2003 1:49 pm Post subject: |
|
|
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 |
|
|
nephros Advocate
Joined: 07 Feb 2003 Posts: 2139 Location: Graz, Austria (Europe - no kangaroos.)
|
Posted: Fri Sep 26, 2003 1:49 pm Post subject: |
|
|
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 |
|
|
jpc82 Guru
Joined: 09 Mar 2003 Posts: 326
|
Posted: Fri Sep 26, 2003 2:16 pm Post subject: |
|
|
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 |
|
|
jpc82 Guru
Joined: 09 Mar 2003 Posts: 326
|
Posted: Fri Sep 26, 2003 2:22 pm Post subject: |
|
|
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 |
|
|
Sieg Tux's lil' helper
Joined: 07 Oct 2002 Posts: 87
|
|
Back to top |
|
|
jpc82 Guru
Joined: 09 Mar 2003 Posts: 326
|
Posted: Fri Sep 26, 2003 2:31 pm Post subject: |
|
|
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 |
|
|
jpc82 Guru
Joined: 09 Mar 2003 Posts: 326
|
Posted: Fri Sep 26, 2003 3:21 pm Post subject: |
|
|
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 |
|
|
CMI Apprentice
Joined: 19 Aug 2003 Posts: 205
|
Posted: Sat Sep 27, 2003 7:35 am Post subject: |
|
|
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 |
|
|
|