On Thu, 9 Nov 2017 12:50:05 -0800
SSC_perl <p...@surfshopcart.com> wrote:

> > On Nov 8, 2017, at 5:16 PM, thelip sia <hei...@gmail.com> wrote:
> > 
> > you can use backtick to store the output.
> > $list = `ssh usern...@domain.com
> > '/usr/bin/perl /path/to/dir-list.pl'`;  
> 
>       Thanks, Heince.  I had mistakenly thought those were
> synonymous with each other.  And, of course, this morning, doing a
> new search produced the backtick solution.  However, every example I
> found was for a unix command, not a perl script.  
> 
>       Using the backticks returns nothing, so perhaps my remote
> script may not be set up properly to "export" it's result?  Sorry -
> I've never dealt with WAN solutions like this before so I don't even
> know how to put it.

Using backticks will capture the output of the script, i.e. what it
wrote to STDOUT.  If it didn't output anything, then you won't get
anything.

[...]
>       As I mentioned, my remote script produces an array of
> directory names that I need to use in my local script.  The array is
> populated correctly, but I can't see it in my local script.

Your script won't see any variables etc that were set in the other
script - all you'll have is a blob of text of whatever it output on
STDOUT.


>       Can the result of a remote script be used in a local script
> by calling it via SSH or some other means?  If so, how do you get the
> result back?  This is not a CGI script - that was only an example
> path I used.

As above, you'll get whatever the script output to STDOUT.

Its output could be just a list of filenames which you can then iterate
over, or it could be some JSON or your serialisation format of
preference which you can then deserialise - whatever you like.


For robustness, you probably want to check $? after using backticks to
see the return status, to know if the remote script was executed
successfully or not.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to