$file should probably be $file = "RPP.OI0800M1";. Also use $ftp->get($file, $path."wip2.rpt"); instead.
Greetz
Beatnik
... Quidquid perl dictum sit, altum viditur. | [reply] [d/l] [select] |
Your problem probably stems from the fact that you are using backslashes (\) in your interpolated (double-quoted) string in your $path assignment. Either use single-quotes or escape your backslashes by doubling them. Your last quotation mark is being interpreted as a literal quotation mark in the string, which is totally screwing up your next few lines of code, because Perl is treating it all as part of the same string. | [reply] [d/l] [select] |
Um, please try your first suggestion youself. ;) \ is still special inside of single quotes and will escape the trailing delimiter, just like it did in the original code. Yes, if the \ is not followed by another \ or your string delimiter (or either of your string delimiters if using nesting delimiters as in q{}), then the \ will be preserved within single quotes. I discourage that because I feel that it leads to mistakes when the \ is followed by one of these characters. If someone as sharp as Fastolfe can get snagged by this, then I think my paranoia is justified. (:
I always double backslashes when I want a backslash unless I'm in a "here doc".
-
tye
(but my friends call me "Tye")
| [reply] |
Well, if I were doing this in my own application, I would have tested my solution first and realized the mistake. You're right, though. Heh.
If you ask me, I hate the fact that back-slashes are special at all within single-quoted strings, precisely for this problem. People make the assumption that single-quotes mean no interpolation is done, that they are safe putting whatever they want in the string. Backslashes are essentially ignored/safe except in the case of a second backslash or a single-quote itself. I might argue that backslashes be totally ignored/unspecial in a single-quoted string. Injecting single quotes might be done by doubling them up.
| [reply] |
Just out of curiosity, why not simply use forwardslashes instead? I use them consistently in win32 applications with no issue. Am I missing something?
| [reply] |
No, you're not. They'll work fine in most any case.
| [reply] |
I agree with the other posts that the / should be in place of the \ mark. You also never used the path of the file. I've run some FTP scripts of my own. I did it this way :
$host = "servername";
$user= "username";
$pw = "password";
$ftp = Net::FTP->new("$host", Debug=>0);
if($ftp){
$ftp->login($user, $pw);
$ftp->cwd("directory_path/subdirectory/here");
$ftp->get("filename_in_directory");
} | [reply] |