Find the answer to your Linux question:
Results 1 to 3 of 3
So I hope the name says it all I have a local xml file that's an argument to a service that i'll be running on a remote box the general ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    May 2006
    Location
    PA
    Posts
    13

    execute remote command with ssh with local file as parameter


    So I hope the name says it all
    I have a local xml file that's an argument to a service that i'll be running on a remote box
    the general idea was something like ssh user(at)remotebox "service localxml"

    this doesn't seem to work when i use a test of
    ssh user(at)remotebox "cat locallist"

    "cat: locallist: No such file or directory"

    any thoughts?

  2. #2
    Linux Enthusiast gerard4143's Avatar
    Join Date
    Dec 2007
    Location
    Canada, Prince Edward Island
    Posts
    714
    I got it to work using:

    Code:
    ssh user@192.168.0.144 /home/user/somedir/someexe < datafile
    The exe was a simple C program:

    someexe.c
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    
    int main(int argc, char**argv)
    {
    	unsigned int ch= 0;
    
    	while ((ch = fgetc(stdin)) != EOF)
    	{
    		fputc(ch, stdout);
    	}
    	exit(EXIT_SUCCESS);
    }
    Make mine Arch Linux

  3. #3
    Just Joined!
    Join Date
    May 2006
    Location
    PA
    Posts
    13
    looks good thanks gerard4143. That looks simpler than my solution
    I did something like
    Code:
    cat "xml" | ssh user@host exe_to_execute
    but i think yours is the same but prettier and easier to understand
    thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •