Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

execute local script on remote machine via ftp & crontab

by igrepstuff (Initiate)
on Aug 03, 2017 at 17:48 UTC ( [id://1196658]=perlquestion: print w/replies, xml ) Need Help??

igrepstuff has asked for the wisdom of the Perl Monks concerning the following question:

I'm a beginner with perl and have been tasked with the following, which I do not understand.

I have a perl script that executes a third party api (via LWP) to obtain attendee information (json format) and load that data into a db. I have been asked to move this script to an internal machine (no web access) and, using ftp and cron jobs, execute the internal perl on a remote machine (with web access).

It doesn't seem to make sense to execute the local script remotely over an ftp connection but I'm not sure whether it is and is just foreign to me. What I'm looking for is something of a birds eye perspective as to how this type of scenario would / should typically be approached.

  • Comment on execute local script on remote machine via ftp & crontab

Replies are listed 'Best First'.
Re: execute local script on remote machine via ftp & crontab
by Mr. Muskrat (Canon) on Aug 03, 2017 at 18:46 UTC

    What you have described is not a Perl problem but you want "a birds eye perspective" so here are two approaches.

    1. Configure the remote machine to act as a proxy for the internal machine. Execute the script on the internal server as described.
    2. Execute the script on a remote machine with web access. Transfer the files to the internal server via SFTP, SCP or another secure protocol*.

    * Forget about FTP or telnet.

Re: execute local script on remote machine via ftp & crontab
by talexb (Chancellor) on Aug 03, 2017 at 19:23 UTC

    As has already been pointed out, this isn't really a Perl specific question.

    It could be that the direction was to use ftp to collect the script from the current machine and move to the new machine. The bad news is that ftp is hilariously insecure -- the username/password is sent in plaintext. Also, the ftp protocol is just used to transfer files (ftp stands File Transfer Protocol, in case you weren't aware); normally, there's no way for you to execute a script using ftp.

    Once the script is moved to the new machine, you could set cron up to run the script at particular times, perhaps saving the result in a directory, possibly with a timestamp so that you could get datasets at difference times. Alternatively, cron could run on your local machine to run the script on the internal server.

    Alex / talexb / Toronto

    Thanks PJ. We owe you so much. Groklaw -- RIP -- 2003 to 2013.

Re: execute local script on remote machine via ftp & crontab
by kcott (Archbishop) on Aug 04, 2017 at 06:53 UTC

    G'day igrepstuff,

    Welcome to the Monastery.

    I have done something fairly similar to this; although, it was a long, long time ago (>15 years). The basic steps, as best as I remember, were:

    1. Use cron to start Perl script on local Unix machine.
    2. Perl script connects, via ftp, to remote MVS machine.
    3. The ftp quote command started COBOL program on MVS machine.
    4. The ftp get command retrieved output from MVS machine.
    5. Retrieved output processed on the local Unix machine.
    6. Rinse and repeat on next cron cycle.

    It was somewhat more involved than that; for instance, there was the ability to monitor progress on the remote machine from the local machine. However, the important bit is that everything, except basic FTP commands (like get), were performed using the quote command.

    I don't know how the commands via quote were set up for the remote machine; it's not something I've ever had to do; I can't help you further with that aspect of your task.

    I suggest you speak to the administrators of your remote machine and discuss your task with them.

    [As already pointed out by others, this in not really a Perl question. We do allow some latitude with off-topic questions; however, please add an [OT] prefix to your question's title. See "How do I change/delete my post?" if you're not sure how to do this. Thankyou.]

    — Ken

Re: execute local script on remote machine via ftp & crontab
by igrepstuff (Initiate) on Aug 04, 2017 at 21:21 UTC

    Thank you all for responding to my question!

    I appreciate that it's not exactly a perl question and also that you did respond and not just dismiss it. Each of your responses has helped. I was able to resolve the issue by keeping my perl script on the web machine, executing it with a cron (encrypt the output) and send the results back via ftp.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1196658]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2024-04-24 05:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found