TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: TopoWAR on December 05, 2012, 11:59:58 AM

Title: ftp upload routine
Post by: TopoWAR on December 05, 2012, 11:59:58 AM
hello teachers, there is a routine that allows uploading files to an ftp server? I know of to lose, but I have not found anything up. Thanks for your attention.
Title: Re: ftp upload routine
Post by: Lee Mac on December 05, 2012, 12:50:17 PM
vla-putremotefile immediately springs to mind, though I'm sure there are more advanced methods by interfacing with ActiveX objects outside of the AutoCAD Object Model.
Title: Re: ftp upload routine
Post by: irneb on December 06, 2012, 04:20:11 AM
One of the oldest threads here: http://www.theswamp.org/index.php?topic=13.0 (http://www.theswamp.org/index.php?topic=13.0)
 
And some more options: http://forums.augi.com/showthread.php?126021-Copy-file-from-Ftp-or-web (http://forums.augi.com/showthread.php?126021-Copy-file-from-Ftp-or-web)
Title: Re: ftp upload routine
Post by: TopoWAR on December 06, 2012, 01:52:03 PM
thanks lee-mac, but know how to apply vla-putremotefile, I know nothing of v-la ...
but I'll try
Title: Re: ftp upload routine
Post by: Lee Mac on December 06, 2012, 06:01:41 PM
thanks lee-mac, but know how to apply vla-putremotefile, I know nothing of vla- ...

putremotefile is a method of the VLA Utility object, hence you would call it as follows:

Code - Auto/Visual Lisp: [Select]
Title: Re: ftp upload routine
Post by: irneb on December 06, 2012, 11:51:11 PM
...you would call it as follows:...
Problem with the highlighted code - the vla-putremotefile links to the index page, but there's no such function listed (as I'd expect since its an ActiveX method - not a normal lisp function).
 
To use these you'd need to check the ActiveX help: http://entercad.ru/acadauto.en/index.html?page=idh_utility_object.htm (http://entercad.ru/acadauto.en/index.html?page=idh_utility_object.htm)
Also available as a chm file in your acad install: C:\Program Files\Common Files\Autodesk Shared\acadauto.chm
Title: Re: ftp upload routine
Post by: TopoWAR on December 07, 2012, 08:39:18 AM
I did as follows but only returns nil, that may be wrong?
(vla-putremotefile
       (vla-get-utility (vla-get-activedocument (vlax-get-acad-object)))
       "http://www.topowar.net/Otros"
       "c:\\leame.txt"
    )

is supposed to ask for the username and password of ftp?
Title: Re: ftp upload routine
Post by: ElpanovEvgeniy on December 07, 2012, 09:15:51 AM
ftp://[User Name]:[Password]@[address]

as exempl:

ftp://UserName:MyPassword@ftp.thest.com
Title: Re: ftp upload routine
Post by: TopoWAR on December 07, 2012, 09:21:37 AM
ElpanovEvgeniy , fantastic, I'll prove it, thank you very much!
Title: Re: ftp upload routine
Post by: bilançikur on December 07, 2012, 10:35:14 AM
Curious about where this might lead to, I tried the next code:

Code: [Select]
(vla-putremotefile
  (vla-get-utility (vla-get-activedocument (vlax-get-acad-object)))
  "ftp://user:password@ftp.domain.com//public//sites//www.domain.com//files//"
  "c:\\test.dwg"
)

It returns:
Code: [Select]
  ;error: Automation Error. Inet: session connect failed
Title: Re: ftp upload routine
Post by: irneb on December 08, 2012, 01:20:09 AM
Could be any one of a number of reasons:
Title: Re: ftp upload routine
Post by: ElpanovEvgeniy on December 08, 2012, 01:55:38 AM
real test:

ftp://anonymous:test@ftp.autodesk.com

old autodesk FTP...
Title: Re: ftp upload routine
Post by: irneb on December 08, 2012, 02:29:11 AM
I think the issue is: this is testing a PUTremotefile. On that site the anonymous user does not have write access, so the function will fail.

The only way to test it would be to use a url to a server with a username which has write access.
Title: Re: ftp upload routine
Post by: Peter2 on May 15, 2017, 02:35:03 AM
Code: [Select]
...  "ftp://user:password@ftp.domain.com//public//sites//www.domain.com//files//"...

I just failed with that code on two different ftp-addresses, and this is why I asked about the syntax of the address above

- "ftp" at the beginning (that's clear)
- "ftp" after @ - I'm not sure ..
- "www" in the middle of the address - ????

Is there some really special to consider?
Title: Re: ftp upload routine
Post by: TopoWAR on May 15, 2017, 10:55:29 AM
I have tried in a thousand ways and I have not managed to make it work, maybe some teacher can collaborate with some test, thanks :-(
Title: Re: ftp upload routine
Post by: irneb on May 17, 2017, 09:39:50 AM
Code: [Select]
...  "ftp://user:password@ftp.domain.com//public//sites//www.domain.com//files//"...Is there some really special to consider?
Not really an issue no.
I have tried in a thousand ways and I have not managed to make it work, maybe some teacher can collaborate with some test, thanks :(
Something weird though ... that code uses double forward slashes. It may just the why this isn't working. You don't need to escape forward slashes, only backslashes. I.e. a "\\" is interpreted as a single \, but a / can simply be used as "/".

Other than that (and the rest of the things previously mentioned) I cannot think of why this shouldn't work. It should rather look like this:
"ftp://user:password@ftp.domain.com/public/sites/www.domain.com/files/"

Title: Re: ftp upload routine
Post by: wkmvrij on May 19, 2017, 06:08:09 PM
You tried:

(vla-putremotefile
       (vla-get-utility (vla-get-activedocument (vlax-get-acad-object)))
       "http://www.topowar.net/Otros"
       "c:\\leame.txt"
    )

From the Autodesk Helpfile on the complimentary function VLA-GETREMOTEFILE:
 

(setq doc (vla-get-ActiveDocument acadObj))

    (setq Utility (vla-get-Utility doc))   ;; Connect to Utility object
   
    ;; Prompt user for a URL to download.  This should be a URL to an AutoCAD drawing file.


I never tried these functions myself, but it seems likely that they are selective of the type of files to be transferred
 
Title: Re: ftp upload routine
Post by: Andrea on May 30, 2017, 02:09:19 PM
just curious....

why not trying to map a drive letter to this FTP....and then,...use vl-file-copy into it ?
Title: Re: ftp upload routine
Post by: Peter2 on May 30, 2017, 03:56:50 PM
Maybe it would work on internal usage, but I see problems if the function runs in a common routine on different, "foreign" PCs.
Title: Re: ftp upload routine
Post by: Andrea on May 30, 2017, 05:19:00 PM
create a VBScript file..
https://www.example-code.com/vbscript/ftp_passiveUpload.asp

then,...call it from lisp... ?
Title: Re: ftp upload routine
Post by: PKENEWELL on June 02, 2017, 04:57:17 PM
Also my example writing a batch file: https://www.theswamp.org/index.php?topic=51824.msg569074#msg569074