> > Dan Muey wrote: > > To answer my own questions : > >> > >> > >> I have 2 questions about this chunk of code I'm trying to > get to work > >> :: I understand that Net::FTP 's stor ... > >> > >> Tells the server to store a new file under the name file. > If the user > >> calls either pasv or port, returns true or false. > Otherwise, returns > >> a reference to a Net::FTP::dataconn object. > >> > >> 1) Is 'server' above the remote server or the local server? > > Remote > >> > >> What I'm trying to do is 'stor' "TEST TEST" in $diry/$ptr1 > >> > >> Here's the code :: > >> > >> 28 - $stor = $ftp->stor("$diry/$ptr1"); > >> 29 - print $stor "TEST TEST"; > >> 30 - close $stor; > >> > >> When I run the script I get this error : > >> > >> Can't use an undefined value as a symbol reference at > ./ftp.pl line > >> 29. > >> > >> I'm figuring that means that $stor isn't defined, what I > can't figure > >> out is > >> > >> 2) why not, or what else can I do to create the file and get TEST > >> TEST into it? > > Why not, couldn't connect so it was blank or ??? > > But this works, and was not easy to figure out from the web > or docs, > > So I hope this helps someone out : To create a file on the remote > > server with contents that were generated in the current script : > > > > $stor = $ftp->stor("$remote_file_name"); > > $stor->write($contents, length($contents)); > # if it's > > a big file you may want to break this up > > $stor->close(); > > Glad you managed to find a solution yourself, but it > definitely does work with 'print' as the object that 'stor' > returns is (amongst other things) an IO::Handle. Does your > $remote_file_name contain the path to the file? If it works > like that I'd be surprised, but the object method may just be
The print way worked for me also now that I did $|=1; and piped STDERR to STOUT and also the $ftp debug to 1, to find my probs, thanks. Actually at first I did the cwd and just used the file name only but while experiementing and trying to figure out What I was doing wrong I removed the cwd and just made the filename variable like 'public_html/file.html' instead Of cwd then file.html and it works like a monkey, so it is more clever than you thought! Although if it may not be portable I'll stick to using cwd. Thanks Dan > cleverer than I thought, although in that case I don't > understand why you were getting an undefined $stor before. > > Rob > > > > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]