{"id":3045,"date":"2020-01-07T16:13:40","date_gmt":"2020-01-07T21:13:40","guid":{"rendered":"http:\/\/bluegalaxy.info\/codewalk\/?p=3045"},"modified":"2020-01-07T16:13:42","modified_gmt":"2020-01-07T21:13:42","slug":"how-to-use-the-linux-od-command-octal-dump","status":"publish","type":"post","link":"https:\/\/bluegalaxy.info\/codewalk\/2020\/01\/07\/how-to-use-the-linux-od-command-octal-dump\/","title":{"rendered":"How to use the Linux od command (Octal Dump)"},"content":{"rendered":"<p>I was in a command terminal &#8220;bash&#8221; window on my Mac and I tried to run this curl command to get a security token from a web service api:<br \/><code>curl -d \"Username=mywebsite&amp;Password=password\" -X POST https:\/\/dev-warehouseapi.somewebsiteservice.com\/api\/Token<\/code><\/p>\n<p>However, my curl command failed with the message &#8220;curl: no URL specified!&#8221;. For example:<\/p>\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"76\" src=\"http:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/01\/image-1-1024x76.png\" alt=\"\" class=\"wp-image-3049\" srcset=\"https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/01\/image-1-1024x76.png 1024w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/01\/image-1-300x22.png 300w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/01\/image-1-768x57.png 768w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/01\/image-1-1536x114.png 1536w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/01\/image-1-2048x152.png 2048w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/01\/image-1-676x50.png 676w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>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&#8217;t visible. <\/p>\n\n\n\n<p>One way to do this is to use the Linux <code>od<\/code> command, which stands for &#8220;Octal Dump&#8221;. This command will output a representation of what each character contains. The complete command looks like this:<\/p>\n\n\n\n<p><code>echo 'curl -d \"Username=mywebsite&amp;Password=password\" -X POST\u00a0https:\/\/dev-warehouseapi.somewebsiteservice.com\/api\/Token' | od -c<\/code><\/p>\n\n\n\n<p>This starts with the <code>echo<\/code> 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 <code>|<\/code> which means to pass the output of the previous command as input to the following command. Finally, I use the <code>od<\/code> command with <code>-c<\/code> as an argument. The <code>-c<\/code> argument tells <code>od<\/code> to show the output in character format. <\/p>\n\n\n\n<p>Here is a screen shot of the complete command along with its output:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"153\" src=\"http:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/01\/image-2-1024x153.png\" alt=\"\" class=\"wp-image-3052\" srcset=\"https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/01\/image-2-1024x153.png 1024w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/01\/image-2-300x45.png 300w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/01\/image-2-768x115.png 768w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/01\/image-2-1536x230.png 1536w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/01\/image-2-2048x307.png 2048w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/01\/image-2-676x101.png 676w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>The special characters shown boxed in red were the hidden characters that were preventing my <code>curl<\/code> 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:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"152\" src=\"http:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/01\/image-3-1024x152.png\" alt=\"\" class=\"wp-image-3053\" srcset=\"https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/01\/image-3-1024x152.png 1024w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/01\/image-3-300x44.png 300w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/01\/image-3-768x114.png 768w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/01\/image-3-1536x227.png 1536w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/01\/image-3-2048x303.png 2048w, https:\/\/bluegalaxy.info\/codewalk\/wp-content\/uploads\/2020\/01\/image-3-676x100.png 676w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Success! <br>This demonstrates the value in using the Linux <code>od<\/code> command to find special  characters that are invisible to the eye. <\/p>\n\n\n\n<p>For more information about the Linux <code>od<\/code> command and other options this command supports, see:<br><a href=\"https:\/\/www.thegeekstuff.com\/2012\/08\/od-command\/\">https:\/\/www.thegeekstuff.com\/2012\/08\/od-command\/<\/a><\/p>\n\n\n\n<p>For more details about the <code>echo<\/code> command, see:<br><a href=\"https:\/\/www.linuxhelp.com\/echo-commands-in-linux-2\">https:\/\/www.linuxhelp.com\/echo-commands-in-linux-2<\/a><\/p>\n\n\n\n<p>For more about the pipe <code>|<\/code> command, see:<br><a href=\"https:\/\/linuxhint.com\/linux_pipe_command\/\">https:\/\/linuxhint.com\/linux_pipe_command\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I was in a command terminal &#8220;bash&#8221; window on my Mac and I tried to run this curl command to get a security token from a web service api:curl -d &#8220;Username=mywebsite&amp;Password=password&#8221; -X POST https:\/\/dev-warehouseapi.somewebsiteservice.com\/api\/Token However, my curl command failed with the message &#8220;curl: no URL specified!&#8221;. For example: My curl command appeared to be perfect, &hellip; <a href=\"https:\/\/bluegalaxy.info\/codewalk\/2020\/01\/07\/how-to-use-the-linux-od-command-octal-dump\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">How to use the Linux od command (Octal Dump)<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[78],"tags":[98,60,217],"class_list":["post-3045","post","type-post","status-publish","format-standard","hentry","category-technologies-and-tools","tag-echo","tag-linux","tag-od"],"_links":{"self":[{"href":"https:\/\/bluegalaxy.info\/codewalk\/wp-json\/wp\/v2\/posts\/3045","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bluegalaxy.info\/codewalk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bluegalaxy.info\/codewalk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bluegalaxy.info\/codewalk\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bluegalaxy.info\/codewalk\/wp-json\/wp\/v2\/comments?post=3045"}],"version-history":[{"count":6,"href":"https:\/\/bluegalaxy.info\/codewalk\/wp-json\/wp\/v2\/posts\/3045\/revisions"}],"predecessor-version":[{"id":3055,"href":"https:\/\/bluegalaxy.info\/codewalk\/wp-json\/wp\/v2\/posts\/3045\/revisions\/3055"}],"wp:attachment":[{"href":"https:\/\/bluegalaxy.info\/codewalk\/wp-json\/wp\/v2\/media?parent=3045"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bluegalaxy.info\/codewalk\/wp-json\/wp\/v2\/categories?post=3045"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bluegalaxy.info\/codewalk\/wp-json\/wp\/v2\/tags?post=3045"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}