Re: Getting the results of a remote script

2017-11-10 Thread Gary Stainburn
Hi Shlomi,

On Friday 10 November 2017 11:52:12 Shlomi Fish wrote:
>
> While I agree, see http://seriot.ch/parsing_json.php for a roundup of
> security problems and inconsistencies in JSON parsers.

Thanks for this, I'll give it a look when I get the chance. Thankfully, so far 
I haven't seen any problems with it's use.
>
> >It also helps when combining PERL and PHP apps
>
> "Perl" is not an acronym - see
> http://perl-begin.org/learn/Perl-perl-but-not-PERL/ and
> https://github.com/perl-doc-cats/perlfaq/blob/master/lib/perlfaq1.pod#whats
>-the-difference-between-perl-and-perl .

I've given in trying to remember which Perl is the right PERL. While the sun 
is still shining, there are better things to spend my time on :D

>
> Regards,
>
>   Shlomi

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




Re: Getting the results of a remote script

2017-11-10 Thread Shlomi Fish
Hi Gary,

On Fri, 10 Nov 2017 09:48:30 +
Gary Stainburn  wrote:

> On Friday 10 November 2017 00:08:09 SSC_perl wrote:
> > > On Nov 9, 2017, at 2:06 PM, David Precious  wrote:
> > >
> > > you'll get whatever the script output to STDOUT.  
> >
> > Thanks a million, Dave!  STDOUT was what I was missing.  I've never
> > used that before, so this was news to me.  The remote script now returns a
> > string that I can manipulate and use in the local script.
> >
> > Thanks again,
> > Frank  
> 
> I would also look at using JSON for anything other than simple examples.  I 
> use this technique extensively for custom peer-to-peer apps. 
> 
> I have even develope a small xinetd service to accept incoming connections.
> 
> This has then enabled me to use Net::telnet in client scripts to generate 
> interactive services. JSON is a good, consistent method of transferring
> data.

While I agree, see http://seriot.ch/parsing_json.php for a roundup of security
problems and inconsistencies in JSON parsers.

>It also helps when combining PERL and PHP apps
> 

"Perl" is not an acronym - see
http://perl-begin.org/learn/Perl-perl-but-not-PERL/ and
https://github.com/perl-doc-cats/perlfaq/blob/master/lib/perlfaq1.pod#whats-the-difference-between-perl-and-perl
 .

Regards,

Shlomi

-- 
-
Shlomi Fish   http://www.shlomifish.org/
http://is.gd/i5eMQd - Emma Watson’s Interview for a Software Dev Job

Chuck Norris once jumped out of a plane, and the parachute did not open. So
instead Chuck Norris opened and brought him and the parachute down safely.
(By Andrew Brehm) — http://www.shlomifish.org/humour/bits/facts/Chuck-Norris/

Please reply to list if it's a mailing list post - http://shlom.in/reply .

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




Re: Getting the results of a remote script

2017-11-10 Thread Gary Stainburn
On Friday 10 November 2017 00:08:09 SSC_perl wrote:
> > On Nov 9, 2017, at 2:06 PM, David Precious  wrote:
> >
> > you'll get whatever the script output to STDOUT.
>
>   Thanks a million, Dave!  STDOUT was what I was missing.  I've never used
> that before, so this was news to me.  The remote script now returns a
> string that I can manipulate and use in the local script.
>
> Thanks again,
> Frank

I would also look at using JSON for anything other than simple examples.  I 
use this technique extensively for custom peer-to-peer apps. 

I have even develope a small xinetd service to accept incoming connections.

This has then enabled me to use Net::telnet in client scripts to generate 
interactive services. JSON is a good, consistent method of transferring data.  
It also helps when combining PERL and PHP apps

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




Re: Getting the results of a remote script

2017-11-09 Thread SSC_perl
> On Nov 9, 2017, at 2:06 PM, David Precious  wrote:
> 
> you'll get whatever the script output to STDOUT.

Thanks a million, Dave!  STDOUT was what I was missing.  I've never 
used that before, so this was news to me.  The remote script now returns a 
string that I can manipulate and use in the local script.

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




Re: Getting the results of a remote script

2017-11-09 Thread David Precious
On Thu, 9 Nov 2017 12:50:05 -0800
SSC_perl  wrote:

> > On Nov 8, 2017, at 5:16 PM, thelip sia  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/




Re: Getting the results of a remote script

2017-11-09 Thread SSC_perl
> On Nov 8, 2017, at 5:16 PM, thelip sia  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.


5 hours later...

I've since decided to offload a portion of my local script to the 
remote script to avoid the back-and-forth.  However, I'm still curious if this 
can even be done.

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.

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.

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




Re: Getting the results of a remote script

2017-11-09 Thread Andy Bach
$list = system('ssh usern...@domain.com '/usr/bin/perl /cgi-bin/dir-list.pl
'");

Hmm, if it's a cgi-bin script, wouldn't use LWP (or curl or ...) work too?

On Wed, Nov 8, 2017 at 6:15 PM, SSC_perl  wrote:

> I have a script on a remote server that creates a list of all
> directories on the server that end in a dash.  I need that list on my
> laptop.  Is it possible to get the result into a variable in my local
> script by triggering the remote script via ssh?  I've tried this:
>
> $list = system('ssh usern...@domain.com '/usr/bin/perl /cgi-bin/
> dir-list.pl'");
>
> but it just returns '0'.  The system call is working fine - I just can't
> get the result returned in $list.
>
> Searching hasn't returned an answer.  Is there another way to get
> what I'm after?
>
> Thanks,
> Frank
> --
> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> For additional commands, e-mail: beginners-h...@perl.org
> http://learn.perl.org/
>
>
>


-- 

a

Andy Bach,
afb...@gmail.com
608 658-1890 cell
608 261-5738 wk


Re: Getting the results of a remote script

2017-11-09 Thread Shlomi Fish
On Thu, 9 Nov 2017 08:16:47 +0700
thelip sia  wrote:

> you can use backtick to store the output.
> $list = `ssh usern...@domain.com '/usr/bin/perl /cgi-bin/dir-list.pl'`;
> 

Indeed, but note that one should be careful when interpolating strings there:

* http://perl-begin.org/topics/security/code-markup-injection/

* https://metacpan.org/pod/String::ShellQuote

Also see
http://perl-begin.org/tutorials/bad-elements/#declaring_all_vars_at_top
regarding predeclaration.


> Regards,
> Heince
> 
> On Thu, Nov 9, 2017 at 7:15 AM, SSC_perl  wrote:
> 
> > I have a script on a remote server that creates a list of all
> > directories on the server that end in a dash.  I need that list on my
> > laptop.  Is it possible to get the result into a variable in my local
> > script by triggering the remote script via ssh?  I've tried this:
> >
> > $list = system('ssh usern...@domain.com '/usr/bin/perl /cgi-bin/
> > dir-list.pl'");
> >
> > but it just returns '0'.  The system call is working fine - I just can't
> > get the result returned in $list.
> >
> > Searching hasn't returned an answer.  Is there another way to get
> > what I'm after?
> >
> > Thanks,
> > Frank
> > --
> > To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> > For additional commands, e-mail: beginners-h...@perl.org
> > http://learn.perl.org/
> >
> >
> >  



-- 
-
Shlomi Fish   http://www.shlomifish.org/

At this point, I'd like to take a moment to speak to you about the Adobe PSD
format. PSD is not a good format. PSD is not even a bad format. Calling it
such would be an insult to other bad formats, such as PCX or JPEG. No, PSD is
an abysmal format.
— https://github.com/gco/xee/blob/master/XeePhotoshopLoader.m

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




Re: Getting the results of a remote script

2017-11-08 Thread thelip sia
you can use backtick to store the output.
$list = `ssh usern...@domain.com '/usr/bin/perl /cgi-bin/dir-list.pl'`;

Regards,
Heince

On Thu, Nov 9, 2017 at 7:15 AM, SSC_perl  wrote:

> I have a script on a remote server that creates a list of all
> directories on the server that end in a dash.  I need that list on my
> laptop.  Is it possible to get the result into a variable in my local
> script by triggering the remote script via ssh?  I've tried this:
>
> $list = system('ssh usern...@domain.com '/usr/bin/perl /cgi-bin/
> dir-list.pl'");
>
> but it just returns '0'.  The system call is working fine - I just can't
> get the result returned in $list.
>
> Searching hasn't returned an answer.  Is there another way to get
> what I'm after?
>
> Thanks,
> Frank
> --
> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> For additional commands, e-mail: beginners-h...@perl.org
> http://learn.perl.org/
>
>
>


Getting the results of a remote script

2017-11-08 Thread SSC_perl
I have a script on a remote server that creates a list of all 
directories on the server that end in a dash.  I need that list on my laptop.  
Is it possible to get the result into a variable in my local script by 
triggering the remote script via ssh?  I've tried this:

$list = system('ssh usern...@domain.com '/usr/bin/perl /cgi-bin/dir-list.pl'");

but it just returns '0'.  The system call is working fine - I just can't get 
the result returned in $list.

Searching hasn't returned an answer.  Is there another way to get what 
I'm after?

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