Launching a process in remote machine


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Launching a process in remote machine
# 1  
Old 10-30-2010
Launching a process in remote machine

Hi all,
Normally to launch a process in the remote machine I will use ssh to the machine and launch the process.I want to launch the remote machine process with out login into the machine . Is there any way.
It may be any workaround method.

Thanks in advance .Smilie
# 2  
Old 10-30-2010
How is the remote box to know when you want to run your job? Telepathy does
not work well in the UNIX world Smilie

With no communication at all:
use cron, set the process to run at a fixed time interval

A> Otherwise there has to be some kind of interaction. If you want system information, try setting up snmp, then request the information when you want it.

B> One system I had long ago: there was a daemon run by a special user account. It read email sent to that account. The subject line was a command to run. The daemon ran the command and emailed the output back. There are huge security issues with this nowadays.

modern way to to B>
nfs mount a filesystem shared on the two boxes. Create/edit files with special names in a restricted directory to do what B> above did.

Bottom line: ssh is much better, even if you have to script it. The choices above (except cron & snmp) can have problems with security
# 3  
Old 10-30-2010
You might also use ftp/sftp to place a trigger file on the remote machine, and have spooler type process run if the file is present, then delete the file.
# 4  
Old 11-02-2010
I run this on HP-UX to SSH to an AIX server.

/homeroot/.rsshpw - contains an encrypted password.
/home/unxsa/sbin/decrypt - is a perl program to decrypt the password.

You will have to put root's ssh passphrase into a file.

Code:
#!/usr/bin/expect -f
#
# Name: ssh_to_node_noninteractively.HP-UX
#
# Purpose: to run a command on a remote machine
#
# Date: June 2010
#
# Version: 1.2
#
# Required Parameters:
# -------------------------------------------------------------------------
#
# Optional Parameters:
# -------------------------------------------------------------------------
#
# Example execution statments:
# -------------------------------------------------------------------------
#
# Variables:
# -------------------------------------------------------------------------
#
# Change History:
# -------------------------------------------------------------------------
# Date          Name            Comments
# _________________________________________________________________________
# June 2010     purdym          new


###################################################################################
# Variables
###################################################################################
set timeout 3
match_max 100000

##################################################################################
# print_options
##################################################################################
if {$argc!=2} {
   send_user "usage: $argv0 hostname command\n"
   exit
}

# script must be run by root user
set whoami [exec id -u]
if {$whoami!=0} {
   send_user "You must be a root user to run this script\n"
   exit
}
###################################################################################
# command line args
###################################################################################
set host [lindex $argv 0]
set command [lindex $argv 1]

###################################################################################
# Start
###################################################################################
# use exec, not spawn here
set password [exec /home/unxsa/sbin/decrypt [exec /usr/bin/cat /homeroot/.rsshpw]]

# opem shell
spawn /usr/bin/ksh

# send passwd command
send -- "ssh -q '$host' '$command'\r"
expect {
   "'/homeroot/.ssh/identity':*" { send "$password\r" }

}

#
expect {
   eof
   timeout close

}

close

###################################################################################
# exit
###################################################################################
exit


Example:

Code:
:/homeroot>uname -a
HP-UX <hidden> B.11.31 U ia64 0489838128 unlimited-user license

:/homeroot>ssh_to_node_noninteractively.HP-UX <hidden> /usr/bin/uname
spawn /usr/bin/ksh
ssh -q '<hidden>' '/usr/bin/uname'
root@wpgux001:/homeroot>ssh -q '<hidden>' '/usr/bin/uname'
Enter passphrase for key '/homeroot/.ssh/identity':
AIX
:/homeroot>



Last edited by purdym; 11-02-2010 at 05:37 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with fetching the data from remote machine from my jumpbox(local machine)

Team, Presently i am running a script from my local box(i.e jumpbox) to all the remote machines.Basically fetching basic queries like pwd,mkdir,touch etc and i am able to successfully fetch it from my local machine.But when i want to check certain database related queries like the dbstat... (20 Replies)
Discussion started by: whizkidash
20 Replies

2. Red Hat

iptables applied in local machine, can't ssh remote machine after chain changed to DROP

I want to SSH to 192.168.1.15 Server from my machine, my ip was 192.168.1.99 Source Destination was UP, with IP 192.168.1.15. This is LAN Network there are 30 Machine's Connected to the network and working fine, I'm Playing around the local machine's because I need to apply the same rules in... (2 Replies)
Discussion started by: babinlonston
2 Replies

3. UNIX for Advanced & Expert Users

FTP While transfering files to local machine to remote machine

Hi Am using unix Ksh Am getting the problem while transferring zero size files through the script . When i transfer zero size files from local machine to remote machine manually i can able to do it . My question its beause of zero size files am not able to transfer through script ? or its... (2 Replies)
Discussion started by: Venkatesh1
2 Replies

4. UNIX for Dummies Questions & Answers

How a process can check if a particular process is running on different machine?

I have process1 running on one machine and generating some log file. Now another process which can be launched on any machine wants to know if process1 is running or not and also in case it is running it wants to stream the logs file generated by process1 on terminal from which process2 is... (2 Replies)
Discussion started by: saurabhnsit2001
2 Replies

5. UNIX for Advanced & Expert Users

Needs help in launching a console application with the help of daemon process

Hi All, I am facing problem in launching a application with the help of a daemon process. Actually the application is based on command line that reads various commands for controlling the application from the console and accordingly executes those commands. The application always interact with... (3 Replies)
Discussion started by: gopallinux
3 Replies

6. Linux

Launching X apps from a machine without X installed

Hi. Here's my setup: a workstation with an X server a CentOS server with no X server installed (development, security is not a concern) a GUI application installed on the server When I ssh to that machine, I get: ssh -Xl root 192.168.x.x Warning: untrusted X11 forwarding setup... (4 Replies)
Discussion started by: flj
4 Replies

7. Red Hat

Problem launching process as BG with &

After i launch the process as back ground, when I try to grab the shell by sending the enter, process is going to Stopped state. How do I successfully run the job in bg with &. Thanks in Advance (1 Reply)
Discussion started by: hansini
1 Replies

8. Red Hat

To find the LATEST file from a dir on REMOTE machine and SCP to local machine?

Hi All, URGENT - Please help me form a scipt for this: I need the LATEST file from a dir on REMOTE machine to be SCP'd to a dir on local machine. (and I need to execute this from local server) I know that the below cmd is used to find the LATEST file from a dir. But this command is not... (3 Replies)
Discussion started by: me_ub
3 Replies

9. UNIX for Dummies Questions & Answers

Tar to remote machine

Is there a way to use Tar (not GNU) to automaticallly create a tar file on a remote machine. the source files will be local, but I would like tthe tar file to be remote. Thanks. (2 Replies)
Discussion started by: hshapiro
2 Replies

10. UNIX for Dummies Questions & Answers

leave a process running in a remote machine

Hi, I would like to run a process in my gentoo machine from a consolte (putty) in Windows and would like that this process keep on going when I close the console in Windows (i.e closing this session). The process should take a long time and I do not want to leave the Windows machine running... (3 Replies)
Discussion started by: pbasil
3 Replies
Login or Register to Ask a Question