perl - Sending gif by ftp to a server in different folders -


i use perl sending gif server. want move gif folder called precipitation , other gifs folder called wind. following code (well, part of code use) send them, there wrong in code, because find gif in same folder, in first one, precipitation. idea?

use bsd::resource; use file::copy; use net::ftp;   #accions  send gif folder precipitation $ftp->cwd("html/pen/precipitation"); foreach $file ($ftp->ls("pl*.gif")){ $ftp->delete($file) or die "error in delete\n"; } @arxius = glob("/home/gif/pen/pl*.gif"); foreach $file(@arxius){ $ftp->binary(); $ftp->put("$file"); }  #accions  send gif folder wind $ftp->cwd("html/pen/wind"); foreach $file2 ($ftp->ls("vent*.gif")){ $ftp->delete($file2) or die "error in delete\n"; } @arxius2 = glob("/home/gif/pen/vent*.gif"); foreach $file(@arxius2){ $ftp->binary(); $ftp->put("$file"); } 

the behavior indicates second call cwd() failed.

most because using relative rather absolute path: second cwd() call relative location set in first one. tries go html/pen/precipitation/html/pen/wind doesn't appear want.

use absolute path or ../wind in second cwd() call.

also, should check success of cwd() commands , stop if didn't change expected directory. otherwise, performing potentially destructive actions (like deleting files) in wrong place!cwd() return true if worked , false otherwise. see net::ftp documentation.


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -