How to use the Linux od command (Octal Dump)

I was in a command terminal “bash” window on my Mac and I tried to run this curl command to get a security token from a web service api:
curl -d "Username=mywebsite&Password=password" -X POST https://dev-warehouseapi.somewebsiteservice.com/api/Token

However, my curl command failed with the message “curl: no URL specified!”. For example:

My curl command appeared to be perfect, so I decided to investigate whether or not there are any special characters hidden in the URL that aren’t visible.

One way to do this is to use the Linux od command, which stands for “Octal Dump”. This command will output a representation of what each character contains. The complete command looks like this:

echo 'curl -d "Username=mywebsite&Password=password" -X POST https://dev-warehouseapi.somewebsiteservice.com/api/Token' | od -c

This starts with the echo command for outputting the characters to the terminal window. Then I paste the string of my original command, surrounded by single quotes in order to escape the double quotes in my command string. After the command string, I use a pipe symbol | which means to pass the output of the previous command as input to the following command. Finally, I use the od command with -c as an argument. The -c argument tells od to show the output in character format.

Here is a screen shot of the complete command along with its output:

The special characters shown boxed in red were the hidden characters that were preventing my curl command from working. This revealed what I needed to do to fix the command string. I just need to delete the special character and ensure that there is only a blank space between POST and https in the command string. Running the fixed command string through the od command yields:

Success!
This demonstrates the value in using the Linux od command to find special characters that are invisible to the eye.

For more information about the Linux od command and other options this command supports, see:
https://www.thegeekstuff.com/2012/08/od-command/

For more details about the echo command, see:
https://www.linuxhelp.com/echo-commands-in-linux-2

For more about the pipe | command, see:
https://linuxhint.com/linux_pipe_command/