LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   Python related: How to access a Perl script behind a firewall from Python? (http://www.linuxquestions.org/questions/programming-9/python-related-how-to-access-a-perl-script-behind-a-firewall-from-python-846017/)

vxc69 11-23-2010 07:35 AM

Python related: How to access a Perl script behind a firewall from Python?
 
Hello,


I have a Perl script behind a firewall. I want to access this script from Python on Google App Engine.

I have access to the server running the Perl script via the following methods:
  1. SSH
  2. VPN

What are the ways I can do this with Python on GAE? Can I use something like wget, login through ssh and run the script using perl interpreter?

Currently it is a CGI script that I can access through a web browser if I'm inside the firewall.

My only other option is to turn the process around, i.e. have perl send data outside the firewall to google app engine. But I want to know if this is possible as it is now without changing the perl script.


Thanks for any help,
:)

Sergei Steshenko 11-24-2010 08:51 AM

Quote:

Originally Posted by vxc69 (Post 4168184)
Hello,


I have a Perl script behind a firewall. I want to access this script from Python on Google App Engine.

I have access to the server running the Perl script via the following methods:
  1. SSH
  2. VPN

What are the ways I can do this with Python on GAE? Can I use something like wget, login through ssh and run the script using perl interpreter?

Currently it is a CGI script that I can access through a web browser if I'm inside the firewall.

My only other option is to turn the process around, i.e. have perl send data outside the firewall to google app engine. But I want to know if this is possible as it is now without changing the perl script.


Thanks for any help,
:)

I'm not getting how 'wget' is related to 'ssh' in this case and why you need 'wget' in the first place.

vxc69 11-24-2010 07:24 PM

I was wondering if it was possible to do it with wget or something similar. Anyway, we're taking the alternative route, make our perl script push data onto GAE from inside the firewall.

Thanks for replying.

Sergei Steshenko 11-25-2010 01:29 AM

Quote:

Originally Posted by vxc69 (Post 4170178)
I was wondering if it was possible to do it with wget or something similar. Anyway, we're taking the alternative route, make our perl script push data onto GAE from inside the firewall.

Thanks for replying.


I do not know what GAE is; 'wget' is a utility to get (i.e. download) file/directories over network, so, again, what does 'wget' have to do with remote execution - this what the thread is about - you need to execute a (Perl) program on remote machine.

So, do you know how to execute, say, 'cd /some/remote/dir; /bin/ls -ltr' on your remote machine ? The answer to this question (if we are talking about interactive shell) is in the very first 9 lines of 'man ssh'.

If you know how to execute the above '/bin/ls', you essentially know how to execute the Perl script in question - at the moment a Perl script has 'x' permission and has as its first line

Code:

#!/usr/bin/perl
# make sure the above path is correct

, it can be invoked as any other executable file, i.e. it really doesn't matter that it's originally written in Perl.

...

P.S. I am not a Python guy; so far I do not see anything Perl/Python specific in the question/issue.

vxc69 11-26-2010 06:24 PM

I don't think you understood my question. The problem was there is a CGI script on a server behind a firewall. People outside the firewall cannot execute the script. And executing this script from outside the firewall is exactly what I wanted to do from python, using an HTTP post.

Since I have access to this server through SSH and VPN, I was wondering how I could tunnel in and then execute the script and get back the results.

I was giving as an example a tool LIKE wget, whether such a tool can carry out such a task, and if anyone knows of such a tool, not wget exactly. I should have left that bit out from my question.

It doesn't matter now, since we modified the perl script to send data out of the firewall. Of course, solutions to the original problem are still welcome.

GAE is google app engine.


Thanks for your replies.

Sergei Steshenko 11-27-2010 04:01 AM

Quote:

Originally Posted by vxc69 (Post 4172207)
...
Since I have access to this server through SSH and VPN, I was wondering how I could tunnel in and then execute the script and get back the results.
...

The "I have access to this server through SSH and VPN" is the answer to your original question - establish a VPN and SSH connection from your Python script and then execute whatever you want. I.e. I do not see a problem in the first place - if you can do something with your fingers and keyboard, you can do the same thing from a program.

vxc69 12-05-2010 02:05 PM

That's is the question then. Tips to "establish a VPN or SSH connection" from python.

Sergei Steshenko 12-05-2010 03:25 PM

Quote:

Originally Posted by vxc69 (Post 4181502)
That's is the question then. Tips to "establish a VPN or SSH connection" from python.

I definitely know there are SSH modules for Perl ( http://search.cpan.org/~turnstep/Net...et/SSH/Perl.pm , http://search.cpan.org/~bnegrao/Net-...SSH/Expect.pod , etc), so most likely there are similar for Python. Even if there is none, 'system' (whatever it's called in Python) still exists.

archtoad6 12-14-2010 07:32 AM

These are friendly suggestions, NOT moderation.

vxc69,

In your OP:

"... Python on Google App Engine (GAE)." instead of "... Python on Google App Engine." would have avoided confusion. I was able to figure out what you meant further down, but only after going back to the beginning.

"something similar to wget" or "something similar to, but necessarily, wget" instead of "something like wget" would have been clearer.

And of course I have the benefit of 20-20 hindsight in making these suggestions. :)


All times are GMT -5. The time now is 06:58 PM.