Have you example using liburl with scp:// ?
Re: Have you example using liburl with scp:// ?
In windows you need the external libcurl.dll, since scp is not included in the internal libcurl.
Code: Select all
EnableExplicit
#LibCurl_DLL$ = "libcurl.dll"
IncludeFile "libcurl.pbi"
ProcedureC.l my_fread(*buffer, Size, NMemB, fd)
Protected Result.i
Result = ReadData(fd, *buffer, (Size & 255) * NMemB)
Debug Str(Result) + " bytes read from file"
ProcedureReturn Result
EndProcedure
Define curl.i, fd.i, res.i, speed_upload.d, total_time.d
fd = ReadFile(#PB_Any, "scp.pb") ; open file to upload
If fd
curl = curl_easy_init()
If curl
; upload To this place
curl_easy_setopt_str(curl, #CURLOPT_URL, "scp://<my_host>:<my_port>/home/xxx/scp.pb")
; adjust user And password
curl_easy_setopt_str(curl, #CURLOPT_USERPWD, "<username>:<password>")
; tell it To "upload" To the URL
curl_easy_setopt(curl, #CURLOPT_UPLOAD, #True)
; set where To Read from (on Windows you need To use READFUNCTION too)
curl_easy_setopt(curl, #CURLOPT_READFUNCTION, @my_fread())
curl_easy_setopt(curl, #CURLOPT_READDATA, fd)
; And give the size of the upload (optional)
; curl_easy_setopt(curl, #CURLOPT_INFILESIZE_LARGE, Lof(fd))
; And give the size of the upload (optional)
curl_easy_setopt(curl, #CURLOPT_INFILESIZE, Lof(fd))
; accept insecure certificates
curl_easy_setopt(curl, #CURLOPT_SSL_VERIFYPEER, #False)
curl_easy_setopt(curl, #CURLOPT_SSL_VERIFYHOST, #False)
; enable verbose For easier tracing
curl_easy_setopt(curl, #CURLOPT_VERBOSE, #True)
res = curl_easy_perform(curl)
If res = #CURLE_OK
; now extract transfer info
curl_easy_getinfo(curl, #CURLINFO_SPEED_UPLOAD, @speed_upload)
curl_easy_getinfo(curl, #CURLINFO_TOTAL_TIME, @total_time)
Debug "Speed: " + StrD(speed_upload, 3) + " bytes/sec during " + StrD(total_time, 3) + " seconds"
Else
Debug "Error: " + curl_easy_strerror(res)
EndIf
; always cleanup
curl_easy_cleanup(curl)
EndIf
CloseFile(fd)
Else
Debug "Was not able to open file"
EndIf
-
- Enthusiast
- Posts: 792
- Joined: Sat Aug 09, 2003 3:13 am
- Location: 90-61-92 // EU or ASIA
- Contact:
Re: Have you example using liburl with scp:// ?
Greatly appreciate your help.
Where to get those files?:
#LibCurl_DLL$ = "libcurl.dll"
IncludeFile "libcurl.pbi"
And has the way to set timeout or which its default timeout?
In fact, i used pscp and one thread with timeout to kill 'pscp process' that be hanged.. that is not always working, so looking for better the way to handle those stuffs. That is why i ask.
Where to get those files?:
#LibCurl_DLL$ = "libcurl.dll"
IncludeFile "libcurl.pbi"
And has the way to set timeout or which its default timeout?
In fact, i used pscp and one thread with timeout to kill 'pscp process' that be hanged.. that is not always working, so looking for better the way to handle those stuffs. That is why i ask.
infratec wrote:In windows you need the external libcurl.dll, since scp is not included in the internal libcurl.
Code: Select all
EnableExplicit #LibCurl_DLL$ = "libcurl.dll" IncludeFile "libcurl.pbi" ProcedureC.l my_fread(*buffer, Size, NMemB, fd) Protected Result.i Result = ReadData(fd, *buffer, (Size & 255) * NMemB) Debug Str(Result) + " bytes read from file" ProcedureReturn Result EndProcedure Define curl.i, fd.i, res.i, speed_upload.d, total_time.d fd = ReadFile(#PB_Any, "scp.pb") ; open file to upload If fd curl = curl_easy_init() If curl ; upload To this place curl_easy_setopt_str(curl, #CURLOPT_URL, "scp://<my_host>:<my_port>/home/xxx/scp.pb") ; adjust user And password curl_easy_setopt_str(curl, #CURLOPT_USERPWD, "<username>:<password>") ; tell it To "upload" To the URL curl_easy_setopt(curl, #CURLOPT_UPLOAD, #True) ; set where To Read from (on Windows you need To use READFUNCTION too) curl_easy_setopt(curl, #CURLOPT_READFUNCTION, @my_fread()) curl_easy_setopt(curl, #CURLOPT_READDATA, fd) ; And give the size of the upload (optional) ; curl_easy_setopt(curl, #CURLOPT_INFILESIZE_LARGE, Lof(fd)) ; And give the size of the upload (optional) curl_easy_setopt(curl, #CURLOPT_INFILESIZE, Lof(fd)) ; accept insecure certificates curl_easy_setopt(curl, #CURLOPT_SSL_VERIFYPEER, #False) curl_easy_setopt(curl, #CURLOPT_SSL_VERIFYHOST, #False) ; enable verbose For easier tracing curl_easy_setopt(curl, #CURLOPT_VERBOSE, #True) res = curl_easy_perform(curl) If res = #CURLE_OK ; now extract transfer info curl_easy_getinfo(curl, #CURLINFO_SPEED_UPLOAD, @speed_upload) curl_easy_getinfo(curl, #CURLINFO_TOTAL_TIME, @total_time) Debug "Speed: " + StrD(speed_upload, 3) + " bytes/sec during " + StrD(total_time, 3) + " seconds" Else Debug "Error: " + curl_easy_strerror(res) EndIf ; always cleanup curl_easy_cleanup(curl) EndIf CloseFile(fd) Else Debug "Was not able to open file" EndIf
Re: Have you example using liburl with scp:// ?
You have so a high level, according to your ICs (or what else they should represent) on the left,
that I thought you are a master and you will know where you can get these files.
If you are not such a master, then you can use this link:
https://www.von-der-salierburg.de/downl ... urldll.zip
You can set a timeout in seconds via:
Or in ms:
From:
https://curl.se/libcurl/c/CURLOPT_TIMEOUT.html
that I thought you are a master and you will know where you can get these files.

If you are not such a master, then you can use this link:
https://www.von-der-salierburg.de/downl ... urldll.zip
You can set a timeout in seconds via:
Code: Select all
curl_easy_setopt(curl, #CURLOPT_TIMEOUT, Timeout)
Code: Select all
curl_easy_setopt(curl, #CURLOPT_TIMEOUT_MS, Timeout)
https://curl.se/libcurl/c/CURLOPT_TIMEOUT.html
Code: Select all
Default timeout is 0 (zero) which means it never times out during transfer.
-
- Enthusiast
- Posts: 792
- Joined: Sat Aug 09, 2003 3:13 am
- Location: 90-61-92 // EU or ASIA
- Contact:
Re: Have you example using liburl with scp:// ?
Its works! Thank you
I have 7 ICs , only 2 active IC

I have 7 ICs , only 2 active IC

infratec wrote:You have so a high level, according to your ICs (or what else they should represent) on the left,
that I thought you are a master and you will know where you can get these files.![]()
If you are not such a master, then you can use this link:
https://www.von-der-salierburg.de/downl ... urldll.zip
You can set a timeout in seconds via:Or in ms:Code: Select all
curl_easy_setopt(curl, #CURLOPT_TIMEOUT, Timeout)
From:Code: Select all
curl_easy_setopt(curl, #CURLOPT_TIMEOUT_MS, Timeout)
https://curl.se/libcurl/c/CURLOPT_TIMEOUT.htmlCode: Select all
Default timeout is 0 (zero) which means it never times out during transfer.