Hi All,
<< First Time Post >>
I have been using Perl for some years, but mostly for Regex/ DBI usage and would like to use it provide a solution for sending files over SFTP via a REST API. The reason for this is that we need to send a couple of thousand files to a remote server, which has the following restriction on the SFTP connection:
- only one connection at at time
- private/ public key authentication with a white list
- 5 minute wait until the next SFTP connection will work
- connection will close if there is more than 30 seconds of idleness
- We have 5 Accounts, so as to spread the load
The team is working on a Java Spring solution to the above . . .. but it taking ages, and l would like to ensure that we have a solution and Perl has always been a faster dev curve for me.
I believe that l need to following:
- Process which listens to a socket, and forks/create-a-thread for each request
- Create a Pool of SFTP connections with Account ID as the primary key for each
- Allow this Pool to be shared amongst other processes
- When the SFTP connection is returned to the Pool:
- we need to run "version" or "ls" every 25 seconds
- wrap the SFTP connection into an object which has a isalive function
- Return success/ failure after each request
I can see quite a few Server libraries, which do 1 and 5 above - but don't understand how l could share an Object (pool of SFTP connections between them) ... and then more importantly, how l can ensure that there is a thread/while-loop keeping the connection alive.
If libraries/ approach can be provided with code samples or pseudo code - that will really help get me started.
Help Ye Old Perl Monks of Lore !
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|