The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
fork and exec ftp KittyJ SUN Solaris 2 08-10-2007 07:55 AM
fork/exec clobbers write. I need ideas why... frequency8 High Level Programming 7 05-29-2007 01:34 AM
FORK/EXEC technique marshmallow UNIX for Dummies Questions & Answers 4 01-18-2007 10:12 PM
rc=127 can't fork BG_JrAdmin Shell Programming and Scripting 1 08-01-2006 06:30 PM
Fork and exec driki High Level Programming 3 05-21-2002 11:45 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-17-2008
looza looza is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 23
Question fork and exec

I need to ssh to a remote server and run my script there. This is my script.

$ssh = "ssh username@host";
$cmd = "$ssh 'cd <my dir> && < sudo Run_exe>'";

my $pid = fork;
if ($pid == 0){
exec $cmd;
}

When I run this I get:
pccons_getchar: got r == 0

Last edited by looza; 07-17-2008 at 11:16 PM..
  #2 (permalink)  
Old 07-18-2008
KevinADC KevinADC is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2008
Posts: 731
assuming perl........

not sure if this is the source of your problem, but the @ symbol is being interpolated as an array because you have it inside a double-quoted string, use single-quotes:

$ssh = 'ssh username@host';

also, when you use exec in perl it does not return back to the perl script, although I am not sure what happens when you run it in a forked process. Try system() or qx//. qx// returns process output back, system() does not. Look them up in the perl documentation.

Next time put Perl in your subject line if that is what you are using.

fork and exec : Perl
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:42 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0