TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started 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.
-
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.
-
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)
-
thanks lee-mac, but know how to apply vla-putremotefile, I know nothing of v-la ...
but I'll try
-
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:
-
...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
-
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?
-
ftp://[User Name]:[Password]@[address]
as exempl:
ftp://UserName:MyPassword@ftp.thest.com
-
ElpanovEvgeniy , fantastic, I'll prove it, thank you very much!
-
Curious about where this might lead to, I tried the next code:
(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:
;error: Automation Error. Inet: session connect failed
-
Could be any one of a number of reasons:
- Username and/or password incorrect
- URL incorrect
- Path not existent
- Insufficient rights to path (i.e. no write access)
- Server down / hanging
-
real test:
ftp://anonymous:test@ftp.autodesk.com
old autodesk FTP...
-
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.
-
... "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?
-
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 :-(
-
... "ftp://user:password@ftp.domain.com//public//sites//www.domain.com//files//"...
Is there some really special to consider?
Not really an issue no.
- The first ftp:// simply states the protocol used.
- The second is because the site's name contains it. Many sites use the same domain name and then a www prefix for their web pages and a ftp prefix for the ftp server.
- The www portion (I'm assuming) is just a folder name in the ftp server's shared folders.
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/"
-
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
-
just curious....
why not trying to map a drive letter to this FTP....and then,...use vl-file-copy into it ?
-
Maybe it would work on internal usage, but I see problems if the function runs in a common routine on different, "foreign" PCs.
-
create a VBScript file..
https://www.example-code.com/vbscript/ftp_passiveUpload.asp
then,...call it from lisp... ?
-
Also my example writing a batch file: https://www.theswamp.org/index.php?topic=51824.msg569074#msg569074