LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Thread Tools
Old 11-07-2009, 04:21 AM   #1
Linuxfan0001
Member
 
Registered: Apr 2008
Posts: 47
Thanked: 0
how to use execv system call to launch remote application on redhat 5?


[Log in to get rid of this advertisement]
Hi
I am trying to use system call execv to launch an application on remote machine.
code snippet:
:
:
char* cmd[] = {"usepwdutility", (char*)0};
ret = execv("/xyz/root/pwdcheck/usepwdutility", cmd);
:
:
where xyz is remote machine name. i also tried substituting ipaddress of the machine in place of machine name. Error it gives is ENOENT

Please let me know in case of any info on this..

Thanks
windows_xp_2003 Linuxfan0001 is offline     Reply With Quote
Old 11-09-2009, 12:38 AM   #2
raskin
Senior Member
 
Registered: Sep 2005
Location: Russia
Distribution: NixOS (http://nixos.org)
Posts: 1,812
Thanked: 23
You cannot just simply run applications on remote computers. If what you tried worked, you could put any name there and execute arbitrary code on arbitrary Internet-connected computers.. a clear security problem.

Probably execvp("ssh", "ssh", "user@host", "command to run");. It is supposed to be ru in terminal; ssh will ask password from user. This, of course, implies that you know a login name of the user on the remote host.
raskin is offline     Reply With Quote
Old 11-09-2009, 12:38 AM   #3
raskin
Senior Member
 
Registered: Sep 2005
Location: Russia
Distribution: NixOS (http://nixos.org)
Posts: 1,812
Thanked: 23
[deleted duplicate]

Last edited by raskin; 11-09-2009 at 12:41 AM.. Reason: Mistaken double-post
raskin is offline     Reply With Quote
Old 11-10-2009, 12:52 AM   #4
Linuxfan0001
Member
 
Registered: Apr 2008
Posts: 47
Thanked: 0

Original Poster
is there any other method to launch application on remote machine?
the scenario is:
Therez an application running on m/c 'A'which tells a deamon process on m/c 'B' to run a program. Now this program and parameters required by it are passed by the application on m/c 'A' to the deamon process running on m/c 'B'. the deamon process waits for the program to complete and sends back the exxit value of the program to the application running on m/c 'A'.
Please let me know the approach to implement above mentioned functionality.
Let me know in case of any clarification required.
Thanks
windows_xp_2003 Linuxfan0001 is offline     Reply With Quote
Old 11-10-2009, 01:02 AM   #5
raskin
Senior Member
 
Registered: Sep 2005
Location: Russia
Distribution: NixOS (http://nixos.org)
Posts: 1,812
Thanked: 23
SSH still meets your needs.
Code:
$ ssh -i ~/.ssh/id_dsa example.com "exit 17" ;
$ echo $?
17
-i allows you to specify "identity" - a secret key. If corresponding public key is added to ~/.ssh/authorize_keys of target user on target computer, and identity file is not protected by password, no password entering is required. Also, SSH returns exit code of remote process as own exit code.

Read "man ssh" and "man sshd".

What you need to keep in mind, though, is that the daemon in your design needs a way to be sure that the application is your nice application, not some spammer trying to send spam using your bandwidth. For ssh thi means that you want to protect your identity files well.
raskin is offline     Reply With Quote
Old 11-10-2009, 02:09 AM   #6
Linuxfan0001
Member
 
Registered: Apr 2008
Posts: 47
Thanked: 0

Original Poster
i want to achieve mentioned functionality programatically. suppose i have remoteapplicationlauncher named out file. using this application i want to programatically send program name and its parameters thati want to run on remote machine.
suppose the application i want to run on remote m/c is usepwdcheckutility and parameters it take is const char* and int. with examples mentioned let me know the code snippet that will be used to achieve the requirement.
Thanks
windows_xp_2003 Linuxfan0001 is offline     Reply With Quote
Old 11-10-2009, 02:10 AM   #7
Linuxfan0001
Member
 
Registered: Apr 2008
Posts: 47
Thanked: 0

Original Poster
execvp("ssh", "ssh", "user@host", "command to run"); does not work...
windows_xp_2003 Linuxfan0001 is offline     Reply With Quote
Old 11-10-2009, 02:19 AM   #8
raskin
Senior Member
 
Registered: Sep 2005
Location: Russia
Distribution: NixOS (http://nixos.org)
Posts: 1,812
Thanked: 23
What happens when you do
Code:
execvp("ssh", "ssh", "user@host", "ls");
? Maybe I was wrong with argument count - then you need
Code:
execvp("ssh", "user@host", "ls");
You are supposed to run the test program in a terminal, by the way. It will be able to run without user interaction when you configure identities.
raskin is offline     Reply With Quote

Reply

Bookmarks


Thread Tools

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
suid application fails to call execv Ron_09 Linux - Newbie 0 05-13-2009 07:44 PM
Problem Running Remote X application on a 10.1 system kaplan71 Suse/Novell 0 04-03-2009 08:44 PM
Starting a Java application from c++ using execv JaseyJaseJase Programming 1 09-17-2008 08:17 PM
how to add my own system call in RedHat linux9.0(2.4.7-20kernel) tyler28 Programming 0 06-15-2005 05:06 AM
NETPERF: ERROR --> send_udp_stream: error on remote: Interrupted system call dravya Linux - General 1 05-29-2004 06:49 PM


All times are GMT -5. The time now is 09:57 PM.

Main Menu
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
RSS2  LQ Podcast
RSS2  LQ Radio
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration