currently busy learning kubernetes and running configs on the command line, and I'm using an M1 MacOS running on version 11.5.1, and one of the commands I wanted to run is curl "http://localhost:8001/api/v1/namespaces/default/pods/$POD_NAME/proxy" but I get the below error message curl: (3) URL using bad/illegal format or missing URL. Not sure if anyone has experienced this issue before, would appreciate the help.
First, curl command should receive only 1 host, not multiple hosts.
Therefore pod should be single.
Then, you need to save POD's name to a variable without any special characters.
Last, when you're using kubectl proxy, you need to add -L option to the curl command so it will follow the redirection.
Simple example will be:
# run pod with echo image
kubectl run echo --image=mendhak/http-https-echo
# start proxy
kubectl proxy
# export pod's name
export POD_NAME=echo
# curl with `-I` - headers and `-L` - follow redirects
curl -IL http://localhost:8001/api/v1/namespaces/default/pods/$POD_NAME/proxy
HTTP/1.1 301 Moved Permanently
Location: /api/v1/namespaces/default/pods/echo/proxy/
HTTP/1.1 200 OK
The problem is that POD_NAME contains two pods separated by space. Therefore the url that you are trying to refer is
malformed - because of space in it - and that's the reason for the error message
wrong - you need to put name of the pod you want to access in there, not both at once
Related
This may be something very simple and obvious but I’m learning the command line. I’m trying to identify the IP address I need to load in a web browser to access my local server - for example, after entering these simple steps in the command line to create a folder with an index file:
mkdir www
nano index.html
Then running the server:
sudo python -m SimpleHTTPServer &
Displays this message: [1] 41749
What IP address do I need to load in a web browser to see the test index.html file? I’ve tried:
http://127.0.0.1/
http://localhost/
Also, entering hostname -i returns this message:
hostname: illegal option -- i
usage: hostname [-fs] [name-of-host]
Can anyone explain what’s going on here? Probably something very obvious. Also it feels that other commands aren’t working as usual as the ip addr command now returns -bash: ip: command not found.
Thanks for any help here.
I have a paid twilio account with verified number and am trying to use the bash script supplied by twilio entitled "twilio-call" on Ubuntu 16.04.3 LTS. The response is: Failed to call 941-8XX-XXXX: curl (22): The requested URL returned: 404 NOT FOUND.
I know that I have the credentials set correctly as the bash script entitled "twilio-sms" works flawlessly.
The bash script "twilio-call" has been downloaded directly from twilio.com/labs/bash and the permissions have been set correctly.
The actual curl command is:
RESPONSE=curl -fSs -u "$ACCOUNTSID:$AUTHTOKEN" -d "Caller=$CALLERID" -d "Called=$PHONE" -d "Url=http://twimlets.com/message?Message=$MSG" "https://api.twilio.com/2008-08-01/Accounts/$ACCOUNTSID/Calls" 2>&1
The variables $ACCOUNTSID, $AUTHTOKEN, $CALLERID, $PHONE, and $MSG have all been verified to be populated correctly.
What could be causing this 404 response? Am I correct in my understanding that a verified number from twilio which works correctly for sms should also work for call?
It must be some old example at Twilio. Where did you find it?
The API endpoint URL it's not
https://api.twilio.com/2008-08-01/Accounts/$ACCOUNTSID/Calls
it is
https://api.twilio.com/2010-04-01/Accounts/$ACCOUNTSID/Calls
Background
I have been searching the Internet trying to find an example of --ftp-create-dirs.
Overall my goal is to use "--ftp-create-dirs" to automatically create the necessary folders if they are not present when I upload my file.
Problem
The problem is I don't know the exact syntax for properly using --ftp-create-dirs, can someone help me with this?
My current curl:
curl -k -T 000-0000-0000-000.png -u [username]:[pass] --ftp-create-dirs /test --ftp-ssl ftp:[ftp server]
In the example above, I am trying to upload the .png image and create /test on the ftp server if it does not exist.
To add a new directory via FTP:
curl ftp://username:password#10.10.10.10/homes/back/newdir/ --ftp-create-dirs
Just putting this in here for future reference (and because I keep making the same mistake that I just saw in your code): it is important to end your folder name with a / (slash). Otherwise, curl will create a file, not a folder. Here is the command I used:
curl -T path/to/local_file.txt ftp://1.2.3.4/my_new_folder/ --ftp-create-dirs -u username:password
This will move local_file.txt to my_new_folder on the FTP server. The folder will be created if it doesn't exist, otherwise, the command will simply be ignored.
If there are any issues with creating the folder, curl will return error number 9 (see https://curl.haxx.se/libcurl/c/libcurl-errors.html). This can happen if a file with the same name as the new folder already exists in the given directory:
curl: (9) Failed to MKD dir: 451
You don't need to use the /test after the --ftp-create-dirs. Its just a parameter similar to your -k(doesn't take any value) at the command.
When I try to use curl command in my shell script I get the following error message: curl: (1) Protocol "http not supported or disabled in libcurl
When I use the curl command with the same http:// argument on my terminal, I get a response from the site. Am I missing something?
Thanks
Update
var4="localhost:8983/xxx?yyy";
var5="-F stream.url=nexus.cvs.ula.abc.html";
var6='"'$var4'" '$var5
curl $var6
The error message
curl: (1) Protocol "http not supported or disabled in libcurl
makes me think that the URL you're passing may be
"http://someserver/somelink"
instead of
http://someserver/somelink
and curl is thinking that " is part of the url.
EDIT:
Based on your update, I'd say it should be:
var4="http://localhost:8983/xxx?yyy";
var5="-F stream.url=nexus.cvs.ula.abc.html";
curl $var5 $var4
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
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?
Just for completeness: this happens also if there are problems on your network.
For instance, to test this, on your local machine shutdown the connection to the internet and try to connect to the URL: the exact same error is returned.
So currently I have no idea of how to distinguish problems on the remote server from problems on our own network.
This could be a DHCP problem. I was seeing the same and similar error messages trying to update and install NPM packages and run Curl commands in my Window WSL2 Ubuntu terminal. After updating the DNS by running sudo echo nameserver 8.8.8.8 > /etc/resolv.conf I was able to install and update packages again. I spent days trying to troubleshoot this and never thought to check for DNS issues.