[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: base64 terminal input failure
From: |
e-letter |
Subject: |
Re: base64 terminal input failure |
Date: |
Fri, 17 Jun 2011 09:38:07 +0100 |
On 17/06/2011, Bob Proulx <address@hidden> wrote:
> e-letter wrote:
>> I have tried to copy base64 encoded text from the clipboard (i.e. a
>> web mail message) to the command terminal:
>>
>> base64 -d 'xyz'
>>
>> where 'xyz' is the base64 text. According to the manual, standard
>> input can be accepted if a file is not accepted but instead the
>> terminal response is:
>>
>> base64: xyz: No such file or directory
>>
>> What is my mistake please?
>
> The base64 syntax is:
>
> base64 [OPTION]... [FILE]
>
> You have specified one option and what appears to the command to be
> one file. The -d fits in the [OPTION] spot and the xyz fits in the
> [FILE] spot.
>
> The brackets indicate that those parts are optional. For [OPTIONS] no
> options means to encode. Specifying -d means to decode.
>
> For [FILE] this means that if a file is specified then the command
> will open the file and read it. If no file is specified on the
> command line then it will read standard input.
>
>> The command:
>> 'echo xyz | base64 -d'
>>
>> returns:
>> �,base64: invalid input
>>
>> If the base64 text is saved as a file, conversion is successful.
>
> This is because "xyz" isn't valid base64 encoded data. It works
> successfully if you give it valid input data instead of random
> characters. See this example:
>
I wrote 'xyz' not as literal, verbatim encoded text but as an example.
Repeating this as follows causes the same error:
...@localhost ~]$ base64 -d Zm9vCg==
base64: Zm9vCg==: No such file or directory
> $ echo foo | base64
> Zm9vCg==
>
> $ echo foo | base64 | base64 -d
> foo
>
> $ echo Zm9vCg== | base64 -d
> foo
>
This occurs, but is not explained in the manual. The manual clearly
states that the option is to be entered before the file/standard
input.