Redirect output to standard out instead of file

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












0














I am writing a java wrapper for convert (which is part of image magick). What I want to do is call a command like convert -thumbnail 1024 test.JPG >(cat) to make it print the thumbnails byte stream to standard out. Afterwards I want to read from this stream and store it in a blob store.
I'm having difficulties with the command above as it looks like it can't handle binary data. After printing the bytes it also prints something like 62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c.



I would like to avoid writing to a temporary file because I don't want to deal with any directory permissions.



What am I doing wrong in my command? Is it cat that can't handle the binary data or is it something else?










share|improve this question

















  • 1




    You may need to use a binary-to-text encoding scheme like Base64 for this to work.
    – Haxiel
    Dec 27 '18 at 13:35










  • @Haxiel you're right, the terminal couldn't handle the binary data but it turns out java can! :-)
    – Selim
    Dec 27 '18 at 14:42















0














I am writing a java wrapper for convert (which is part of image magick). What I want to do is call a command like convert -thumbnail 1024 test.JPG >(cat) to make it print the thumbnails byte stream to standard out. Afterwards I want to read from this stream and store it in a blob store.
I'm having difficulties with the command above as it looks like it can't handle binary data. After printing the bytes it also prints something like 62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c.



I would like to avoid writing to a temporary file because I don't want to deal with any directory permissions.



What am I doing wrong in my command? Is it cat that can't handle the binary data or is it something else?










share|improve this question

















  • 1




    You may need to use a binary-to-text encoding scheme like Base64 for this to work.
    – Haxiel
    Dec 27 '18 at 13:35










  • @Haxiel you're right, the terminal couldn't handle the binary data but it turns out java can! :-)
    – Selim
    Dec 27 '18 at 14:42













0












0








0







I am writing a java wrapper for convert (which is part of image magick). What I want to do is call a command like convert -thumbnail 1024 test.JPG >(cat) to make it print the thumbnails byte stream to standard out. Afterwards I want to read from this stream and store it in a blob store.
I'm having difficulties with the command above as it looks like it can't handle binary data. After printing the bytes it also prints something like 62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c.



I would like to avoid writing to a temporary file because I don't want to deal with any directory permissions.



What am I doing wrong in my command? Is it cat that can't handle the binary data or is it something else?










share|improve this question













I am writing a java wrapper for convert (which is part of image magick). What I want to do is call a command like convert -thumbnail 1024 test.JPG >(cat) to make it print the thumbnails byte stream to standard out. Afterwards I want to read from this stream and store it in a blob store.
I'm having difficulties with the command above as it looks like it can't handle binary data. After printing the bytes it also prints something like 62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c62;c.



I would like to avoid writing to a temporary file because I don't want to deal with any directory permissions.



What am I doing wrong in my command? Is it cat that can't handle the binary data or is it something else?







bash io-redirection imagemagick






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Dec 27 '18 at 13:16









SelimSelim

1033




1033







  • 1




    You may need to use a binary-to-text encoding scheme like Base64 for this to work.
    – Haxiel
    Dec 27 '18 at 13:35










  • @Haxiel you're right, the terminal couldn't handle the binary data but it turns out java can! :-)
    – Selim
    Dec 27 '18 at 14:42












  • 1




    You may need to use a binary-to-text encoding scheme like Base64 for this to work.
    – Haxiel
    Dec 27 '18 at 13:35










  • @Haxiel you're right, the terminal couldn't handle the binary data but it turns out java can! :-)
    – Selim
    Dec 27 '18 at 14:42







1




1




You may need to use a binary-to-text encoding scheme like Base64 for this to work.
– Haxiel
Dec 27 '18 at 13:35




You may need to use a binary-to-text encoding scheme like Base64 for this to work.
– Haxiel
Dec 27 '18 at 13:35












@Haxiel you're right, the terminal couldn't handle the binary data but it turns out java can! :-)
– Selim
Dec 27 '18 at 14:42




@Haxiel you're right, the terminal couldn't handle the binary data but it turns out java can! :-)
– Selim
Dec 27 '18 at 14:42










2 Answers
2






active

oldest

votes


















2














From the Output Filename section of the command-line processing web page:




Standard Out



Unix permits the output of one command to be piped to another. ImageMagick permits piping one command to another with a filename of -.



In this example we pipe the output of convert to the display program:



magick logo: gif:- | display gif:-




Your command-line could then start with:



convert -thumbnail 1024 test.JPG - 


... or optionally converted to other formats with the proper prefix:



convert -thumbnail 1024 test.JPG png:-


... at which point you could then pipe that output to your blob-store-reader:



convert -thumbnail 1024 test.JPG - | blob-store-reader





share|improve this answer




















  • This did the trick, thanks! I should've read the docs more thoroughly..
    – Selim
    Dec 27 '18 at 14:43



















1














cat is made for lines and text, but it doesn't care if it's handling binary data except for a few control characters. It's the terminal (your normal stdout) that can't cope with binary data and presumably gets stuck.



BTW, using "process substitution" for the required output file is like taking the scenic route. And, you should use it correctly, adding another > for the redirection. But, why at all? man convert:




Specify 'file' as '-' for standard input or output.







share|improve this answer




















    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "106"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f491124%2fredirect-output-to-standard-out-instead-of-file%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    2














    From the Output Filename section of the command-line processing web page:




    Standard Out



    Unix permits the output of one command to be piped to another. ImageMagick permits piping one command to another with a filename of -.



    In this example we pipe the output of convert to the display program:



    magick logo: gif:- | display gif:-




    Your command-line could then start with:



    convert -thumbnail 1024 test.JPG - 


    ... or optionally converted to other formats with the proper prefix:



    convert -thumbnail 1024 test.JPG png:-


    ... at which point you could then pipe that output to your blob-store-reader:



    convert -thumbnail 1024 test.JPG - | blob-store-reader





    share|improve this answer




















    • This did the trick, thanks! I should've read the docs more thoroughly..
      – Selim
      Dec 27 '18 at 14:43
















    2














    From the Output Filename section of the command-line processing web page:




    Standard Out



    Unix permits the output of one command to be piped to another. ImageMagick permits piping one command to another with a filename of -.



    In this example we pipe the output of convert to the display program:



    magick logo: gif:- | display gif:-




    Your command-line could then start with:



    convert -thumbnail 1024 test.JPG - 


    ... or optionally converted to other formats with the proper prefix:



    convert -thumbnail 1024 test.JPG png:-


    ... at which point you could then pipe that output to your blob-store-reader:



    convert -thumbnail 1024 test.JPG - | blob-store-reader





    share|improve this answer




















    • This did the trick, thanks! I should've read the docs more thoroughly..
      – Selim
      Dec 27 '18 at 14:43














    2












    2








    2






    From the Output Filename section of the command-line processing web page:




    Standard Out



    Unix permits the output of one command to be piped to another. ImageMagick permits piping one command to another with a filename of -.



    In this example we pipe the output of convert to the display program:



    magick logo: gif:- | display gif:-




    Your command-line could then start with:



    convert -thumbnail 1024 test.JPG - 


    ... or optionally converted to other formats with the proper prefix:



    convert -thumbnail 1024 test.JPG png:-


    ... at which point you could then pipe that output to your blob-store-reader:



    convert -thumbnail 1024 test.JPG - | blob-store-reader





    share|improve this answer












    From the Output Filename section of the command-line processing web page:




    Standard Out



    Unix permits the output of one command to be piped to another. ImageMagick permits piping one command to another with a filename of -.



    In this example we pipe the output of convert to the display program:



    magick logo: gif:- | display gif:-




    Your command-line could then start with:



    convert -thumbnail 1024 test.JPG - 


    ... or optionally converted to other formats with the proper prefix:



    convert -thumbnail 1024 test.JPG png:-


    ... at which point you could then pipe that output to your blob-store-reader:



    convert -thumbnail 1024 test.JPG - | blob-store-reader






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Dec 27 '18 at 14:12









    Jeff SchallerJeff Schaller

    39k1054125




    39k1054125











    • This did the trick, thanks! I should've read the docs more thoroughly..
      – Selim
      Dec 27 '18 at 14:43

















    • This did the trick, thanks! I should've read the docs more thoroughly..
      – Selim
      Dec 27 '18 at 14:43
















    This did the trick, thanks! I should've read the docs more thoroughly..
    – Selim
    Dec 27 '18 at 14:43





    This did the trick, thanks! I should've read the docs more thoroughly..
    – Selim
    Dec 27 '18 at 14:43














    1














    cat is made for lines and text, but it doesn't care if it's handling binary data except for a few control characters. It's the terminal (your normal stdout) that can't cope with binary data and presumably gets stuck.



    BTW, using "process substitution" for the required output file is like taking the scenic route. And, you should use it correctly, adding another > for the redirection. But, why at all? man convert:




    Specify 'file' as '-' for standard input or output.







    share|improve this answer

























      1














      cat is made for lines and text, but it doesn't care if it's handling binary data except for a few control characters. It's the terminal (your normal stdout) that can't cope with binary data and presumably gets stuck.



      BTW, using "process substitution" for the required output file is like taking the scenic route. And, you should use it correctly, adding another > for the redirection. But, why at all? man convert:




      Specify 'file' as '-' for standard input or output.







      share|improve this answer























        1












        1








        1






        cat is made for lines and text, but it doesn't care if it's handling binary data except for a few control characters. It's the terminal (your normal stdout) that can't cope with binary data and presumably gets stuck.



        BTW, using "process substitution" for the required output file is like taking the scenic route. And, you should use it correctly, adding another > for the redirection. But, why at all? man convert:




        Specify 'file' as '-' for standard input or output.







        share|improve this answer












        cat is made for lines and text, but it doesn't care if it's handling binary data except for a few control characters. It's the terminal (your normal stdout) that can't cope with binary data and presumably gets stuck.



        BTW, using "process substitution" for the required output file is like taking the scenic route. And, you should use it correctly, adding another > for the redirection. But, why at all? man convert:




        Specify 'file' as '-' for standard input or output.








        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Dec 27 '18 at 14:18









        RudiCRudiC

        4,2191312




        4,2191312



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Unix & Linux Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f491124%2fredirect-output-to-standard-out-instead-of-file%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown






            Popular posts from this blog

            How to check contact read email or not when send email to Individual?

            Displaying single band from multi-band raster using QGIS

            How many registers does an x86_64 CPU actually have?