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

Hi, I've been looking around here and I can't find anything to address this particular problem, so I thought I should ask. I'm still a real newbie to Perl so my apologies if it's something obvious I'm overlooking.

Anyway, regarding the problem: I've tried encoding the @ as x{0040}
I've tried escaping it (\@)
I've tried passing the username directly instead of through a variable
I get the same error message every time:
>> "Can't use an undefined value as a symbol reference"

I know the login details are correct because I've tested logging onto the host via FileZilla and had no issues. I know the rest of the script is fine because I've FTP'd files to another host (which didn't have an "@" in the username). I'm all out of ideas on how to get around this now, though. Any ideas?

  • Comment on Is there a workaround for @ symbol in FTP username?

Replies are listed 'Best First'.
Re: Is there a workaround for @ symbol in FTP username?
by tmharish (Friar) on Feb 20, 2013 at 10:36 UTC

    A bit of the code will help - without that all I can say is use diagnostics and single quotes?

      Oh, sorry. Sure, the code is below. I had to change the actual details (of course), but the format is the same. I'm using single quotes already, though. So it shouldn't read the "@" as a special character, right?
      my $un = 'username@domain.com; my $pw = 'password'; print "- FTPing report... "; my $ftp; my $status = 1; my ($connectattempts, $putattempts, $cwdattempts, $loginattempts) = +(0,0,0,0); STARTFTP: $ftp = Net::FTP->new("host.com", Debug => 0, Passive => 0) or $statu +s = 0; if (!$status) { if ($connectattempts < 3) { $connectattempts++; print "Session failed, retrying in 60 seconds\n"; $status = 1; sleep 60; goto STARTFTP; } else { goto FAILED; } } $status = $ftp->login($un,$pw); if (!$status) { if ($loginattempts < 3) { $loginattempts++; print "Login failed, retrying in 60 seconds\n"; $status = 1; sleep 60; goto STARTFTP; } else { goto FAILED; } } $ftp->binary(); $status = $ftp->put($outputfile,$outputfile); if (!$status) { if ($putattempts < 3) { $putattempts++; print "PUT command failed, retrying in 60 seconds\n"; $status = 1; sleep 60; goto STARTFTP; } else { goto FAILED; } } $ftp->quit; print "$file successfully uploaded.\n"; unlink $file; return 1; FAILED: print "$file was not transferred to host.com! Please upload manually +!\n\n"; return 0; }
      Thanks for looking at this.
        A peek at the Net::FTP sourcecode shows that $user is almost everywhere getting @host.com appended before being used. Which begs the question, why do you create a new ftp object to host.com, then try to connect to domain.com through the username?

        I don't know if credentials such as user@domain.com@host.com are allowed, but it looks fishy and overcomplicated. I can't immediately see where the error message is coming from, but maybe a troll with the debugger will set you straight?

        Have you tried setting the hostname only in new?

        -QM
        --
        Quantum Mechanics: The dreams stuff is made of

         my $un = 'username@domain.com;

        No close quote?? Am looking at the rest ...