[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Remote upload

Posted on 2011-10-14
8
Medium Priority
?
211 Views
Last Modified: 2012-05-12
Hi,
________________________________________________________
#!/bin/perl
use Net::FTP;
print "Enter the file name:";
chomp ($file = <STDIN>);
chomp ($user = 'xxxx@yyyy.com');

$ftp = Net::FTP->new("ftp.abc.com",Debug => 3);
$ftp->login("$user","c6b4b8e1");
$ftp->binary();
$ftp->put("$file");
$ftp->quit;
_________________________________________________________

FTP login get failed due to bad username,
above script is not accepting email id as username

can someone suggest?
0
Comment
Question by:pravink22
8 Comments
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 36969760
No FTP access that I have uses the email address as the username.  It could be the username without the '@yyy.com' which is common on my Linux hosting.  Sometimes the FTP username and password is entirely different from the account name.
0
 

Author Comment

by:pravink22
ID: 36969883
without "@yyy.com", I can't enter into ftp account manually
0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 36970119
Maybe you need to 'escape' the '@' so it will be entered literally instead as defining a variable?
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:pravink22
ID: 36970128
can I get with program?
0
 

Author Comment

by:pravink22
ID: 36970347
DaveBaldwin:
Maybe you need to 'escape' the '@' so it will be entered literally instead as defining a variable?

Open in new window


Can you write a script for this?
0
 
LVL 16

Expert Comment

by:AlexPace
ID: 36970362
This might be off-topic or it might be exactly what you need: It is common for public FTP sites to expect a login like this:

USER anonymous
PASS joe@abc.com
0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 36971174
@pravink22, sorry I had to go away for a while.  I can't find anywhere that says exactly what to do.  The '@' has special meaning in Perl and that could be throwing it off.  Try this:

chomp ($user = 'xxxx\@yyyy.com');
0
 
LVL 28

Accepted Solution

by:
FishMonger earned 2000 total points
ID: 36972050
EVERY Perl script you write should begin with these 2 pragmas.
use strict;
use warnings;

Open in new window


Why are you applying chomp to the statically assigned $user var, which doesn't include a line terminator?

Add a die statements to the object creation and login which include the reason it failed.

Don't quote single vars.  See: perldoc -q quoting

Are you able to login from the command line using the same username and password?

Have you tried enabling passive mode?

Since you're using single quotes when assigning $user, you don't need to worry about escaping the '@' symbol.

Try this updated version and report back with the results and include a copy/paste of the output.

#!/bin/perl

use strict;
use warnings;
use Net::FTP;

print "Enter the file name:";
chomp (my $file = <STDIN>);

my $user = 'xxxx@yyyy.com';
my $host = 'ftp.abc.com';

my $ftp = Net::FTP->new( $host, Debug => 3, Passive => 1 )
        or die "Cannot connect to '$host': $@";

$ftp->login( $user, "c6b4b8e1" ) or die "Cannot login ", $ftp->message;
$ftp->binary();
$ftp->put($file);
$ftp->quit;

Open in new window

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans
Suggested Courses

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question