Is there a way to do FTP-SSL with Perl's Net::FTP module? - perl

I'm working on a project that requires me to download files from FTP using Perl. I just found out that I've got the option to use FTP-SSL. It seems that this is just SSL encrypted FTP (similar to HTTP vs. HTTPS) and I should just have to send the "AUTH TLS" or "AUTH SSL" commands to the FTP server.
The question: is there a way to do this with the standard Net::FTP? I've checked the docs and the only thing I've found about it is use the "features" function to find out if the server supports it.
I found the Net::FTPSSL module on CPAN, but the author says sometimes the server does not receive the data that was sent. That doesn't sound like something I want to put into production.

Short answer: no.
From looking at the source of Net::FTP I'd say it's not possible to use SSL with it. I'd rather test if Net::FTPSSL works with the FTP server you're going to use your program with. If your program needs to be able to work with any FTP server, you might want to try and fix the module for those servers it doesn't work with and contribute your code to the original module.

Related

Scripted FTP Upload from Container

I am trying to upload a file from a container field to a location on FTP as a serverside script. I have been trying to use the Base Elements BE_FTP_Upload as I'm lead to believe this works on a server script, however I just simply cannot get it to work, I've had the file on FTP, but its always blank missing the content.
I should also add that the BE_Curl_Trace feedback shows successful connection to the FTP, it seems to be my method of moving the file rather than a bad connection. Script attached. (excuse the squiggles, data protection and what not.)
After all of this, simply changing the "filewin:" to "file:" solved my problem, I am now exporting from FM to FTP via a scheduled server script :)

lighttpd - don't terminate on invalid ssl key/cert?

I'm using lighty on an embedded device where power-users are allowed to manipulate the system configuration using an web interface. The users can upload an PEM file containing valid private key and certificate information.
Now I wonder how to avoid that lighty will not start if the file is corrupt? One idea is to check the file before installing it, but it seems that there is no easy solution.
My other idea is to configure lighty in a way that it will recognize the file is invalid (it does in fact) but it should not terminate. Instead it should run without SSL features, so HTTP only.
Is there a way to configure lighty for that? or is there a better solution?
This should provide just enough check options for your need
openssl verify --help
You could use a perlscript to comment out any ssl related config block if the cert check fails, but that is beyond this question.
Of course you need to edit the init/service script which starts lighttpd/lighttpd.service

Query a remote server's operating system?

is there a way to query a server for its OS type in Perl? For example, if I knew that a remote server was running Windows, I might send it a winver from my local machine and get the output to determine which version of Windows it's running. Yet, is there a way to be even more abstract and simply ask "what are you?"
Since CPAN is huge, I was wondering if there were a module that encapsulated this sort of functionality.
If you can get command-line access on the remove server, then you should be able to use %ENV:
jmaney> perl -e 'print "$ENV{OSTYPE}\n";'
linux
Edit: It looks as though the key in Windows (or, at least on Windows 7 on my laptop) is OS. So, unfortunately, the exact solution via %ENV is OS-dependent... You could, however, check to see which of $ENV{OS} or $ENV{OSTYPE} is defined (and if they're both defined, then canonically pick which one you want to use), and proceed accordingly.
There is no foolproof way to do this, but the HTTP Server header -- which the server isn't required to send -- often contains the OS. For example, it may look like this (from Wikipedia):
Server: Apache/1.3.27 (Unix) (Red-Hat/Linux)
The Perl CGI module has an http function that gets the HTTP headers. You could use it like this:
my $server = $q->http('Server');
# Test $server for Windows, *nix, etc
# My Perl experience is minimal and I haven't used it in
# a while, so I'm not going to give an example here, but
# someone can feel free to edit one in.
CPAN probably has a module to do the testing on the Server header for you.

PHP Slow to process soap request via browser but fine on the command line

I am trying to connect to an external SOAP service using PHP and have written a small php test script that just connects to the service and performs a simple request to check everything is working.
This all works correctly but when I run via a browser request, it is very slow taking somewhere in the region of 40s to establish the initial connection. When I do the same request using the exact same script on the command line, it goes through straight away.
Does anyone have any ideas as to why this might be?
Cheers
PHP caches the wsdl in /tmp. If you run from the command line first, the cache file will be owned by whatever user you're running the script as, and apache won't be able to read the cache. The wsdl will have to be downloaded and parsed every time which will be slow.
Check the permissions of /tmp/wsdl*.
Maybe external SOAP service trying to check your IP, and your server has ICMP allowed, when your local network - not.
Anyway, this question might be answered more clearly by administrator of external SOAP service :)
Is there a difference between the php.inis that are being used?
On a standard ubuntu server installation:
diff /etc/php5/apache2/php.ini /etc/php5/cli/php.ini
//edit:
Another difference might be in the include paths. Had this trouble myself on a local test server, it didn't actually use the soap class that was included (it didn't include anything, because the search paths weren't valid), but it included the built-in soap_client class.

FTP a site from local host to server

I know this is a very basic question.I am new to web programming.Im working with a CMS.My client has asked me to 'FTP' the site that i am manipulating on my local machine, so that he can view the changes too.He also gave a link on cliking which, the site pops up in its original form.I understand that its hosted on a server and i am suposed to make it look like the one i have modified on local.How do i do this?using an FTP client.What about the database?
And also what if something goes wrong during the process?Is it undoable?
I would have done much more research before asking this question, but i have got so little time to figure this out.Thnks
Encourage your client to use scp or sftp instead. It'll encrypt the login and traffic.
Get an FTP program like WSFTP.
What about the database? You need a copy of the database on the server (which is presumably where the link goes).
Get the login/pass from the client.
It's un-doable if you have a copy or backup of the original.
FTP copies files from one machine to another. Sounds like you need to install the CMS on the server.
Need more information: what CMS, is it already on the server, what database?