I am having a problem with my bash script. It is producing an error of
curl (6) couldn't resolve host
What have I done wrong?
The following is my bash script.
#!/bin/bash
string="$(mysql -u root -p Company 'select name from HR')"
url="http://www.company.com/company/hr/$string"
curl -F $url
cURL error 6. The error indicates that the network that UpdraftPlus is attempting to connect to is unreachable. This shows that the connection isn't being blocked, but is failing to reach the UpdraftPlus.com servers.
The reason curl fails is simply because the DNS resolution is missing.
Since the hostname is missing and your system is not able to figure out the hostname and thus it throws the error 'sudo: unable to resolve host'. To fix this error, edit the /etc/hosts file and set the hostname (newpc) with a loopback address (127.0. 0.1).
According to the man curl, error 6 means "Couldn't resolve host. The given remote host was not resolved." so you will have to check if the hostname of the url is resolvable to an ip address.
when you need to submit data to a server, for example with the form below,
<form method="POST" enctype='multipart/form-data' action="upload.cgi">
<input type=file name=upload>
<input type=submit name=press value="OK">
</form>
you can do it curl with the following equivalent. (make sure the server that you submitted is ready to receive the data too)
curl -F upload=@localfilename -F press=OK [resolv-able url]
Try printing out the whole string/url. I believe it should have some problems in it.
And can you ping "www.company.com" (I'm assuming that's not the real name you're connecting to) at all?
And it might be worthwhile printing out the $url
variable before you curl
it since it may be malformed.
And one final thing. Are you sure you should be using -F
? This appears to be automated form filling. Is it possible you wanted to "fail silently" option -f
?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With