dwortman
asked on
Using cURL and SFTP
Is there a way to modify what I use below to transfer a file automatically but using SFTP? It is ran from a BASH script.
LOCALPATH="/tmp/data/"
USER="myusername"
PASS="mypassword"
FTP="999.99.99.11"
MODE="w"
FILENAME="Report.txt"
curl --disable-epsv --ftp-create-dirs -B -T $LOCALPATH$FILENAME ftp://$USER:$PASS@$FTP/SystemReview/$FILENAME
LOCALPATH="/tmp/data/"
USER="myusername"
PASS="mypassword"
FTP="999.99.99.11"
MODE="w"
FILENAME="Report.txt"
curl --disable-epsv --ftp-create-dirs -B -T $LOCALPATH$FILENAME ftp://$USER:$PASS@$FTP/SystemReview/$FILENAME
ASKER
Yves Accad,
Based on your comments I created this command:
curl -k -u username:mypassword -T /tmp/data/df.txt sftp://IPAddress:/SystemReview
But I get an error message saying:
Couldn’t resolve host ‘IPAddress’
I verified that the IP Address I am using is correct.
Thanks
Based on your comments I created this command:
curl -k -u username:mypassword -T /tmp/data/df.txt sftp://IPAddress:/SystemReview
But I get an error message saying:
Couldn’t resolve host ‘IPAddress’
I verified that the IP Address I am using is correct.
Thanks
ASKER
I ran it again with the -v switch and got this message:
* getaddrinfo(3) failed for IPAddress:22
* Couldn't resolve host 'IPAddress:'
* Closing connection #0
curl: (6) Couldn't resolve host 'IPAddress:'
* getaddrinfo(3) failed for IPAddress:22
* Couldn't resolve host 'IPAddress:'
* Closing connection #0
curl: (6) Couldn't resolve host 'IPAddress:'
This sounds like you are using 'IPAddress' instead of the Ip address of your SFTP server. If you're using variables you probably need to refer to it as $IPAddress. But try putting the actual IP without using the variables first to test that it works.
In the example below I use an example IP and this works in my environment:
In the example below I use an example IP and this works in my environment:
curl -k -u username:mypassword -T /tmp/data/df.txt sftp://192.168.1.1:/SystemReview
ASKER
Thanks for the reply. I do use the numerical IP address but I cannot display it in a public forum (that is what I was told). For purposes of EE it is an alias like username and mypassword.
The error message you are receiving indicates that curl is somehow trying to resolve that value, which means it's not seeing it as a numerical IP address but rather as a host name and trying to resolve it. That's why I made the above assumption. What version of curl are you running? I'm using version 7.55.1 and the above command does exactly what you're asking for. Let me know your version and I can dig further.
Thanks.
Thanks.
ASKER
I have version 7.21.1
Thanks and have a great weekend...
Thanks and have a great weekend...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yves,
Thanks for the help. We do not currently have ssh on our client server and this is something that we need to discuss in-house over the next few days. I am closing this ticket to assign you the points.
Thanks again
Thanks for the help. We do not currently have ssh on our client server and this is something that we need to discuss in-house over the next few days. I am closing this ticket to assign you the points.
Thanks again
Open in new window