Re: can VFP 9 ftp a file??? by Ben
Ben
Tue Nov 29 16:14:33 CST 2005
No problem and I don't think you're stupid man. Read some of my previous
posts LOL....
For kicks try putting the functon only in a separate .prg (ex: MyFuncs.prg)
then do this
1.) Set procedure to'c:\wherever\MyFuncs.Prg' additive
2.) CreateUploadBat
('c:\windows\system32','c:\','','myuser','mypassword','ftp://ftpipaddress','file
to send')
Then stop here, check to be sure the upload.bat and FtpRpt.Scr files are
created, if yes then add these lines:
3.) cCmd='c:\upload.bat'
4.) run &cCmd
If the .bat file is not created you might want to return a .t. or .f. from
CreateUploadBat(...) so you can see if was successfull. This can be
accomplished by setting a numeric variable on the StrToFile line.
Ex: nError=StrToFile((cScrString,cRptDir+'FtpRpt.scr')
if nError=0
return .f.
else
return .t.
endif
"Bubba Gump Shrimp" <none@microsoft.com> wrote in message
news:O7TWGxS9FHA.2844@TK2MSFTNGP10.phx.gbl...
> Man I must be really stupid cuz I just can't make it work. If I put it all
> at the bottom of my little simple program, how should it be constructed?
>
> Also, if I'm using an ip address, does it need to have ftp:// in front of
> it for it to work?
>
> This is what i put at the end of my program and i get no transfer attempt.
> (I've includede line numbers below at the start of each line to show what
> all is on a single line in case something's wrong and word wrap here makes
> it appear wrong.
>
> 1. function
> CreateUploadBat(cFtpDir,cRptDir,cUploadDir,cUser,cPw,cIp,cFileName)
> 2.
> cBatString=alltrim(cFtpDir)+'ftp -i -n -s:'+cRptDir+'FtpRpt.scr'+alltrim(cIp)
> 3. strtofile(cBatString,cRptDir+'Upload.bat')
> 4.
> cScrString='user'+CrLf()+cUser+CrLf()+cPw+CrLf()+'cd'+cUploadDir+CrLf()+'mput
> '+cRptDir+cFileName+CrLf()+'quit'
> 5. strtofile(cScrString,cRptDir+'FtpRpt.scr')
> 6. RETURN
>
> 1. CreateUploadBat ('c:\windows\system32','directory where file to send
> resides','','myuser','mypassword','ftp://ftpipaddress','file to send')
> 2. cCmd='c:\upload.bat'
> 3. run &cCmd\
>
> It is not creating the batch file anywhere and it's not creating a
> FtpRpt.scr anywhere.
>
> Thanks for your patience.
>
> Buster
>
> "Ben" <nospam@nospam.com> wrote in message
> news:uH2jf.69$1U2.57@tornado.rdc-kc.rr.com...
>>I store like functions in a single .prg file then do a
>>
>> Set procedure to (cDefprog) + 'common.prg' additive
>>
>> in the main.prg so it doesn't matter where the function sits in relation
>> to the call to that function.
>>
>>
>> "Bubba Gump Shrimp" <none@microsoft.com> wrote in message
>> news:e3UE95R9FHA.2576@TK2MSFTNGP12.phx.gbl...
>>> Shouldn't the function come first so it can be defined before you create
>>> the run the createuploadbat command? So then it would appear like this:
>>>
>>> function
>>> CreateUploadBat(cFtpDir,cRptDir,cUploadDir,cUser,cPw,cIp,cFileName)
>>> cBatString=alltrim(cFtpDir)+'ftp -i -n -s:'+cRptDir+'FtpRpt.scr
>>> '+alltrim(cIp)
>>> strtofile(cBatString,cRptDir+'Upload.bat')
>>> cScrString='user'+CrLf()+cUser+CrLf()+cPw+CrLf()+'cd
>>> '+cUploadDir+CrLf()+'mput '+cRptDir+cFileName+CrLf()+'quit'
>>> strtofile(cScrString,cRptDir+'FtpRpt.scr')
>>> return
>>>
>>>
>>> CreateUploadBat('c:\windows\system32\','c:\','','ben','ben','www.ftp.com','autoexec.bat')
>>> cCmd='c:\upload.bat'
>>> run &cCmd
>>>
>>> Thanks Ben!
>>>
>>> "Ben" <nospam@nospam.com> wrote in message
>>> news:hU1jf.118$f41.34@tornado.rdc-kc.rr.com...
>>>> subfolder isn't needed. I just ran this and it worked.
>>>>
>>>> CreateUploadBat('c:\windows\system32\','c:\','','ben','ben','www.ftp.com','autoexec.bat')
>>>> cCmd='c:\upload.bat'
>>>> run &cCmd
>>>>
>>>> you'll need to include this function.
>>>>
>>>> function
>>>> CreateUploadBat(cFtpDir,cRptDir,cUploadDir,cUser,cPw,cIp,cFileName)
>>>> cBatString=alltrim(cFtpDir)+'ftp -i -n -s:'+cRptDir+'FtpRpt.scr
>>>> '+alltrim(cIp)
>>>> strtofile(cBatString,cRptDir+'Upload.bat')
>>>> cScrString='user'+CrLf()+cUser+CrLf()+cPw+CrLf()+'cd
>>>> '+cUploadDir+CrLf()+'mput '+cRptDir+cFileName+CrLf()+'quit'
>>>> strtofile(cScrString,cRptDir+'FtpRpt.scr')
>>>> return
>>>>
>>>>
>>>>
>>>> "Ben" <nospam@nospam.com> wrote in message
>>>> news:Ny1jf.115$f41.25@tornado.rdc-kc.rr.com...
>>>>> Give me 15 mins and I'll hook you up. BRB....
>>>>>
>>>>> "Bubba Gump Shrimp" <none@microsoft.com> wrote in message
>>>>> news:u6VMyMR9FHA.1148@tk2msftngp13.phx.gbl...
>>>>>> ok, I took that 9out. Trying to get it to work and it appears to work
>>>>>> in that I get no errors but the file doesn't upload and I don't see
>>>>>> an upload.bat file on the C drive.
>>>>>>
>>>>>> I didn't specify a subfolder to upload to, is that needed?
>>>>>>
>>>>>> I changed the file to be uploaded (*.bat) in the CreateUploadBat line
>>>>>> to be the actual txt filename that I need it to upload. Correct?
>>>>>>
>>>>>> Thanks Ben!
>>>>>> Buster
>>>>>>
>>>>>> I did verify my ftp.exe is in the windows\system32 folder so I left
>>>>>> that path in tact.
>>>>>> "Ben" <nospam@nospam.com> wrote in message
>>>>>> news:VX0jf.110$f41.3@tornado.rdc-kc.rr.com...
>>>>>>> Yep...but I noticed a mistake when I trimmed out custome code I left
>>>>>>> in a reference to (cDefHtml) in the cCmd string, you can get rid of
>>>>>>> that.
>>>>>>>
>>>>>>> Been posting questions here a while, first time I think I've
>>>>>>> actually answered one! hehe.
>>>>>>>
>>>>>>> - Ben
>>>>>>>
>>>>>>>
>>>>>>> "Bubba Gump Shrimp" <none@microsoft.com> wrote in message
>>>>>>> news:uAR5h$Q9FHA.3876@TK2MSFTNGP09.phx.gbl...
>>>>>>>> This may be the easiest thing to do then in all honesty. So once I
>>>>>>>> get my output file, I can simply insert this code at the bottom of
>>>>>>>> my already created program. Correct?
>>>>>>>>
>>>>>>>> Thanks!
>>>>>>>>
>>>>>>>> "Ben" <nospam@nospam.com> wrote in message
>>>>>>>> news:LH0jf.96$Dk.69@tornado.rdc-kc.rr.com...
>>>>>>>>> [my previous post had the cr and lf stripped]
>>>>>>>>>
>>>>>>>>> "Ben" <nospam@nospam.com> wrote in message
>>>>>>>>> news:5D0jf.95$Dk.1@tornado.rdc-kc.rr.com...
>>>>>>>>> There are a few ways to tackle this. What I ended up doing was
>>>>>>>>> creating a
>>>>>>>>> func that writes a batch file calling the windows FTP command and
>>>>>>>>> then run
>>>>>>>>> it. May not be the best way but it's worked very reliably
>>>>>>>>> hundreds of times
>>>>>>>>> a day....
>>>>>>>>>
>>>>>>>>> Code looks something like this:
>>>>>>>>>
>>>>>>>>> CreateUploadBat('c:\windows\system32','c:\','SubFolder/','user','password','111.222.333.444','*.bat')
>>>>>>>>> cCmd=(cDefhtml)+'c:\Upload.bat'
>>>>>>>>> run &cCmd
>>>>>>>>>
>>>>>>>>> ************************************************************************
>>>>>>>>> function
>>>>>>>>> CreateUploadBat(cFtpDir,cRptDir,cUploadDir,cUser,cPw,cIp,cFileName)
>>>>>>>>> cBatString=alltrim(cFtpDir)+'ftp -i -n -s:'+cRptDir+'FtpRpt.scr'+alltrim(cIp)
>>>>>>>>> strtofile(cBatString,cRptDir+'Upload.bat')
>>>>>>>>> cScrString='user'+CrLf()+cUser+CrLf()+cPw+CrLf()+'cd'+cUploadDir+CrLf()+'mput
>>>>>>>>> '+cRptDir+cFileName+CrLf()+'quit'
>>>>>>>>> strtofile(cScrSt