Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

net::ftp help

Status
Not open for further replies.

timcarr

Programmer
Jan 10, 2001
23
ZA
I'm calling a perl script on an NT machine that should FTP a file from a folder on the IFS to a library on the AS/400.
I'm new to perl so any help is appreciated.


use Net::FTP;

$hostname = 'host';
$username = 'user';
$password = 'password';

$file = 'path/file.txt';
$remote = 'library.lib/file.member';

$ftp = Net::FTP->new($hostname);
$ftp->login($username, $password);
$ftp->put($file, $remote);
$ftp->quit;
 
Your code looks ok as far as I can tell. I copied it to my machine and ran it with one modification. I do not have write permissions to an ftp server, so I used get instead of put. Additionally, I used 'anonymous' as my user and an email looking string for a password, first.last@some.server.com. Worked fine. I have changed my server info below to keep ner'-do-wells away.

#!/usr/local/bin/perl
use Net::FTP;

$hostname = 'ftp.some.server.com';
$username = 'anonymous';
$password = 'first.last@someserver.com';

$file = '/local/path/to/file.extension';

$ftp = Net::FTP->new($hostname);
$ftp->login($username, $password);
$ftp->get($file);
$ftp->quit;

Can you tell us anything about error messages or other stuff that might help us diagnose your problem????



keep the rudder amid ship and beware the odd typo
 
You're right, the code was ok... It was part of a larger file and something above wasn't allowing it to even start (so I wasn't getting any error messages).

I got that to work, but now I've ran into another problem. I need to check the value of a text box to see if the first character is a number and then I'll set a variable if it is...

Here is the part of the script this deals with:

-------------------------------
if (
($textbox eq ????)
) { $noerror = 1; }
else { $noerror = 0; }
-------------------------------

I have no idea what to put where the question marks are...

Thanks
 
You will need to use pattern matching rather than 'eq'. Pattern matching will allow you to check for classes of characters.

if ($textbox =~ /^\d/) { $noerror = 1; }

The =~ is the pattern match operator.
The / and / are the pattern delimiters. Look for what's in between.
The ^ says start at the front end of $textbox when checking for a match.
The \d says any digit.
So, if ($textbox matches /start with a digit/) { $noerror = 1; }

' Hope this is what you were looking for.



keep the rudder amid ship and beware the odd typo
 
That's exactly what I was looking for.

Thanks a bunch!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top