Passing empty string as program parameter












1















I do the following:



$ ./input ""


Output:



argc 2
argv[1][0] 0


But if I want to pass (several) empty quotes in program based manner:



$ python -c 'print """"'
""

./input $(python -c 'print """"')


gives:



argc 2
argv[1][0] 22 - (22 hex value for ")


So how can I generate something like



$ ./input "" "" "" ""


and get result same as in example 1 ?










share|improve this question

























  • You should post your C code too.

    – Tomasz
    36 mins ago











  • Why do you need it? It is clear from a context that is prints argc and argv[1][0] as a hex value.

    – Alex Hoppus
    23 mins ago
















1















I do the following:



$ ./input ""


Output:



argc 2
argv[1][0] 0


But if I want to pass (several) empty quotes in program based manner:



$ python -c 'print """"'
""

./input $(python -c 'print """"')


gives:



argc 2
argv[1][0] 22 - (22 hex value for ")


So how can I generate something like



$ ./input "" "" "" ""


and get result same as in example 1 ?










share|improve this question

























  • You should post your C code too.

    – Tomasz
    36 mins ago











  • Why do you need it? It is clear from a context that is prints argc and argv[1][0] as a hex value.

    – Alex Hoppus
    23 mins ago














1












1








1








I do the following:



$ ./input ""


Output:



argc 2
argv[1][0] 0


But if I want to pass (several) empty quotes in program based manner:



$ python -c 'print """"'
""

./input $(python -c 'print """"')


gives:



argc 2
argv[1][0] 22 - (22 hex value for ")


So how can I generate something like



$ ./input "" "" "" ""


and get result same as in example 1 ?










share|improve this question
















I do the following:



$ ./input ""


Output:



argc 2
argv[1][0] 0


But if I want to pass (several) empty quotes in program based manner:



$ python -c 'print """"'
""

./input $(python -c 'print """"')


gives:



argc 2
argv[1][0] 22 - (22 hex value for ")


So how can I generate something like



$ ./input "" "" "" ""


and get result same as in example 1 ?







bash c arguments






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 49 mins ago









Tomasz

9,42852965




9,42852965










asked 1 hour ago









Alex HoppusAlex Hoppus

1429




1429













  • You should post your C code too.

    – Tomasz
    36 mins ago











  • Why do you need it? It is clear from a context that is prints argc and argv[1][0] as a hex value.

    – Alex Hoppus
    23 mins ago



















  • You should post your C code too.

    – Tomasz
    36 mins ago











  • Why do you need it? It is clear from a context that is prints argc and argv[1][0] as a hex value.

    – Alex Hoppus
    23 mins ago

















You should post your C code too.

– Tomasz
36 mins ago





You should post your C code too.

– Tomasz
36 mins ago













Why do you need it? It is clear from a context that is prints argc and argv[1][0] as a hex value.

– Alex Hoppus
23 mins ago





Why do you need it? It is clear from a context that is prints argc and argv[1][0] as a hex value.

– Alex Hoppus
23 mins ago










2 Answers
2






active

oldest

votes


















2














in



./input $(cmd)


Because, $(cmd) is unquoted, that's a split+glob operator. The shell retrieves the output of cmd, removes all the trailing newline characters, then splits that based on the value of the $IFS special parameter, and then performs filename generation (for instance turns *.txt into the list of non-hidden txt files in the current directory) on the resulting words (that latter part not with zsh) and in the case of ksh also performs brace expansion (turns a{b,c} into ab and ac for instance).



The default value of $IFS contains the SPC, TAB and NL characters (also NUL in zsh, other shells either remove the NULs or choke on them). Those (not NUL) also happen to be IFS-whitespace character, which are treated specially when it comes to IFS-splitting.



If the output of cmd is " a bnc n", that split+glob operator will generate a "a", "b" and "c" arguments to ./input. With IFS-white-space characters, it's impossible for split+glob to generate an empty argument because sequences of one or more IFS-whitespace characters are treated as one delimiter. To generate an empty argument, you'd need to choose a separator that is not an IFS-whitespace character. Actually, any character but SPC, TAB or NL will do (best to also avoid multi-byte characters which are not supported by all shells here).



So for instance if you do:



IFS=:          # split on ":" which is not an IFS-whitespace character
set -o noglob # disable globbing (also brace expansion in ksh)
./input $(cmd)


And if cmd outputs a::bn, then that split+glob operator will result in "a", "" and "b" arguments (note that the "s are not part of the value, I'm just using them here to help show the values).



With a:b:n, depending on the shell, that will result in "a" and "b" or "a", "b" and "". You can make it consistent across all shells with



./input $(cmd)""


(which also means that for an empty output of cmd (or an output consisting only of newline characters), ./input will receive one empty argument as opposed to no argument at all).



Example:



cmd() {
printf 'a b:: cn'
}
input() {
printf 'I got %d arguments:n' "$#"
[ "$#" -eq 0 ] || printf ' - <%s>n' "$@"
}
IFS=:
set -o noglob
input $(cmd)


gives:



I got 3 arguments:
- <a b>
- <>
- < c>


Also note that when you do:



./input ""


Those " are part of the shell syntax, they are shell quoting operators. Those " characters are not passed to input.






share|improve this answer

































    2














    But what do you want to pass in fact? Empty quotes or empty strings? Both are valid arguments and this simple bash script can help illustrate this:



    #!/bin/bash

    printf "Argument count: %s.n" "${#@}"


    It just prints the number of arguments passed to it. I'll call it s for brevity.



    $ ./s a
    Argument count: 1.
    $ ./s a b
    Argument count: 2.
    $ ./s a b ""
    Argument count: 3.
    $ ./s a b "" ""
    Argument count: 4.
    $ ./s a b "" "" ""
    Argument count: 5.


    As you can see the empty strings are just empty strings - the quotes are removed at parsing time - and they're still valid arguments. The shell feeds them into the command. But "" can be passed on as well. It's not an empty string though. It contains two characters.



    Under the hood, for C, strings are NUL () terminated and no quotes are needed to represent them.






    share|improve this answer
























    • Mmm... Let's put it in a different way: I want pass 100 empty quotes. In C program empty quote passed as a parameter is a string which contains only 0x00. I can do it easy for one parameter like i said: ./input "" , but if i need 100 NULL parameters, it is hard to type in console ./input "" "" "" "" "" .... so i want to generate this command.

      – Alex Hoppus
      26 mins ago













    • @AlexHoppus Then you need 100 NULs and xargs: $ perl -e'print""x100' | xargs -0 ./s.

      – Tomasz
      19 mins ago











    • Okay I have already done this via xargs, but the problem is that this ./input program also have an stdin input (the program reads some values using scanf()). And if i do python -c 'print "x00 "*65+" \nr"+"x00 "*34' | xargs ./input i don't know how to pass this input to my app (./input) when it is launched via xargs

      – Alex Hoppus
      15 mins ago













    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%2f496843%2fpassing-empty-string-as-program-parameter%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














    in



    ./input $(cmd)


    Because, $(cmd) is unquoted, that's a split+glob operator. The shell retrieves the output of cmd, removes all the trailing newline characters, then splits that based on the value of the $IFS special parameter, and then performs filename generation (for instance turns *.txt into the list of non-hidden txt files in the current directory) on the resulting words (that latter part not with zsh) and in the case of ksh also performs brace expansion (turns a{b,c} into ab and ac for instance).



    The default value of $IFS contains the SPC, TAB and NL characters (also NUL in zsh, other shells either remove the NULs or choke on them). Those (not NUL) also happen to be IFS-whitespace character, which are treated specially when it comes to IFS-splitting.



    If the output of cmd is " a bnc n", that split+glob operator will generate a "a", "b" and "c" arguments to ./input. With IFS-white-space characters, it's impossible for split+glob to generate an empty argument because sequences of one or more IFS-whitespace characters are treated as one delimiter. To generate an empty argument, you'd need to choose a separator that is not an IFS-whitespace character. Actually, any character but SPC, TAB or NL will do (best to also avoid multi-byte characters which are not supported by all shells here).



    So for instance if you do:



    IFS=:          # split on ":" which is not an IFS-whitespace character
    set -o noglob # disable globbing (also brace expansion in ksh)
    ./input $(cmd)


    And if cmd outputs a::bn, then that split+glob operator will result in "a", "" and "b" arguments (note that the "s are not part of the value, I'm just using them here to help show the values).



    With a:b:n, depending on the shell, that will result in "a" and "b" or "a", "b" and "". You can make it consistent across all shells with



    ./input $(cmd)""


    (which also means that for an empty output of cmd (or an output consisting only of newline characters), ./input will receive one empty argument as opposed to no argument at all).



    Example:



    cmd() {
    printf 'a b:: cn'
    }
    input() {
    printf 'I got %d arguments:n' "$#"
    [ "$#" -eq 0 ] || printf ' - <%s>n' "$@"
    }
    IFS=:
    set -o noglob
    input $(cmd)


    gives:



    I got 3 arguments:
    - <a b>
    - <>
    - < c>


    Also note that when you do:



    ./input ""


    Those " are part of the shell syntax, they are shell quoting operators. Those " characters are not passed to input.






    share|improve this answer






























      2














      in



      ./input $(cmd)


      Because, $(cmd) is unquoted, that's a split+glob operator. The shell retrieves the output of cmd, removes all the trailing newline characters, then splits that based on the value of the $IFS special parameter, and then performs filename generation (for instance turns *.txt into the list of non-hidden txt files in the current directory) on the resulting words (that latter part not with zsh) and in the case of ksh also performs brace expansion (turns a{b,c} into ab and ac for instance).



      The default value of $IFS contains the SPC, TAB and NL characters (also NUL in zsh, other shells either remove the NULs or choke on them). Those (not NUL) also happen to be IFS-whitespace character, which are treated specially when it comes to IFS-splitting.



      If the output of cmd is " a bnc n", that split+glob operator will generate a "a", "b" and "c" arguments to ./input. With IFS-white-space characters, it's impossible for split+glob to generate an empty argument because sequences of one or more IFS-whitespace characters are treated as one delimiter. To generate an empty argument, you'd need to choose a separator that is not an IFS-whitespace character. Actually, any character but SPC, TAB or NL will do (best to also avoid multi-byte characters which are not supported by all shells here).



      So for instance if you do:



      IFS=:          # split on ":" which is not an IFS-whitespace character
      set -o noglob # disable globbing (also brace expansion in ksh)
      ./input $(cmd)


      And if cmd outputs a::bn, then that split+glob operator will result in "a", "" and "b" arguments (note that the "s are not part of the value, I'm just using them here to help show the values).



      With a:b:n, depending on the shell, that will result in "a" and "b" or "a", "b" and "". You can make it consistent across all shells with



      ./input $(cmd)""


      (which also means that for an empty output of cmd (or an output consisting only of newline characters), ./input will receive one empty argument as opposed to no argument at all).



      Example:



      cmd() {
      printf 'a b:: cn'
      }
      input() {
      printf 'I got %d arguments:n' "$#"
      [ "$#" -eq 0 ] || printf ' - <%s>n' "$@"
      }
      IFS=:
      set -o noglob
      input $(cmd)


      gives:



      I got 3 arguments:
      - <a b>
      - <>
      - < c>


      Also note that when you do:



      ./input ""


      Those " are part of the shell syntax, they are shell quoting operators. Those " characters are not passed to input.






      share|improve this answer




























        2












        2








        2







        in



        ./input $(cmd)


        Because, $(cmd) is unquoted, that's a split+glob operator. The shell retrieves the output of cmd, removes all the trailing newline characters, then splits that based on the value of the $IFS special parameter, and then performs filename generation (for instance turns *.txt into the list of non-hidden txt files in the current directory) on the resulting words (that latter part not with zsh) and in the case of ksh also performs brace expansion (turns a{b,c} into ab and ac for instance).



        The default value of $IFS contains the SPC, TAB and NL characters (also NUL in zsh, other shells either remove the NULs or choke on them). Those (not NUL) also happen to be IFS-whitespace character, which are treated specially when it comes to IFS-splitting.



        If the output of cmd is " a bnc n", that split+glob operator will generate a "a", "b" and "c" arguments to ./input. With IFS-white-space characters, it's impossible for split+glob to generate an empty argument because sequences of one or more IFS-whitespace characters are treated as one delimiter. To generate an empty argument, you'd need to choose a separator that is not an IFS-whitespace character. Actually, any character but SPC, TAB or NL will do (best to also avoid multi-byte characters which are not supported by all shells here).



        So for instance if you do:



        IFS=:          # split on ":" which is not an IFS-whitespace character
        set -o noglob # disable globbing (also brace expansion in ksh)
        ./input $(cmd)


        And if cmd outputs a::bn, then that split+glob operator will result in "a", "" and "b" arguments (note that the "s are not part of the value, I'm just using them here to help show the values).



        With a:b:n, depending on the shell, that will result in "a" and "b" or "a", "b" and "". You can make it consistent across all shells with



        ./input $(cmd)""


        (which also means that for an empty output of cmd (or an output consisting only of newline characters), ./input will receive one empty argument as opposed to no argument at all).



        Example:



        cmd() {
        printf 'a b:: cn'
        }
        input() {
        printf 'I got %d arguments:n' "$#"
        [ "$#" -eq 0 ] || printf ' - <%s>n' "$@"
        }
        IFS=:
        set -o noglob
        input $(cmd)


        gives:



        I got 3 arguments:
        - <a b>
        - <>
        - < c>


        Also note that when you do:



        ./input ""


        Those " are part of the shell syntax, they are shell quoting operators. Those " characters are not passed to input.






        share|improve this answer















        in



        ./input $(cmd)


        Because, $(cmd) is unquoted, that's a split+glob operator. The shell retrieves the output of cmd, removes all the trailing newline characters, then splits that based on the value of the $IFS special parameter, and then performs filename generation (for instance turns *.txt into the list of non-hidden txt files in the current directory) on the resulting words (that latter part not with zsh) and in the case of ksh also performs brace expansion (turns a{b,c} into ab and ac for instance).



        The default value of $IFS contains the SPC, TAB and NL characters (also NUL in zsh, other shells either remove the NULs or choke on them). Those (not NUL) also happen to be IFS-whitespace character, which are treated specially when it comes to IFS-splitting.



        If the output of cmd is " a bnc n", that split+glob operator will generate a "a", "b" and "c" arguments to ./input. With IFS-white-space characters, it's impossible for split+glob to generate an empty argument because sequences of one or more IFS-whitespace characters are treated as one delimiter. To generate an empty argument, you'd need to choose a separator that is not an IFS-whitespace character. Actually, any character but SPC, TAB or NL will do (best to also avoid multi-byte characters which are not supported by all shells here).



        So for instance if you do:



        IFS=:          # split on ":" which is not an IFS-whitespace character
        set -o noglob # disable globbing (also brace expansion in ksh)
        ./input $(cmd)


        And if cmd outputs a::bn, then that split+glob operator will result in "a", "" and "b" arguments (note that the "s are not part of the value, I'm just using them here to help show the values).



        With a:b:n, depending on the shell, that will result in "a" and "b" or "a", "b" and "". You can make it consistent across all shells with



        ./input $(cmd)""


        (which also means that for an empty output of cmd (or an output consisting only of newline characters), ./input will receive one empty argument as opposed to no argument at all).



        Example:



        cmd() {
        printf 'a b:: cn'
        }
        input() {
        printf 'I got %d arguments:n' "$#"
        [ "$#" -eq 0 ] || printf ' - <%s>n' "$@"
        }
        IFS=:
        set -o noglob
        input $(cmd)


        gives:



        I got 3 arguments:
        - <a b>
        - <>
        - < c>


        Also note that when you do:



        ./input ""


        Those " are part of the shell syntax, they are shell quoting operators. Those " characters are not passed to input.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited 9 mins ago

























        answered 26 mins ago









        Stéphane ChazelasStéphane Chazelas

        302k56568921




        302k56568921

























            2














            But what do you want to pass in fact? Empty quotes or empty strings? Both are valid arguments and this simple bash script can help illustrate this:



            #!/bin/bash

            printf "Argument count: %s.n" "${#@}"


            It just prints the number of arguments passed to it. I'll call it s for brevity.



            $ ./s a
            Argument count: 1.
            $ ./s a b
            Argument count: 2.
            $ ./s a b ""
            Argument count: 3.
            $ ./s a b "" ""
            Argument count: 4.
            $ ./s a b "" "" ""
            Argument count: 5.


            As you can see the empty strings are just empty strings - the quotes are removed at parsing time - and they're still valid arguments. The shell feeds them into the command. But "" can be passed on as well. It's not an empty string though. It contains two characters.



            Under the hood, for C, strings are NUL () terminated and no quotes are needed to represent them.






            share|improve this answer
























            • Mmm... Let's put it in a different way: I want pass 100 empty quotes. In C program empty quote passed as a parameter is a string which contains only 0x00. I can do it easy for one parameter like i said: ./input "" , but if i need 100 NULL parameters, it is hard to type in console ./input "" "" "" "" "" .... so i want to generate this command.

              – Alex Hoppus
              26 mins ago













            • @AlexHoppus Then you need 100 NULs and xargs: $ perl -e'print""x100' | xargs -0 ./s.

              – Tomasz
              19 mins ago











            • Okay I have already done this via xargs, but the problem is that this ./input program also have an stdin input (the program reads some values using scanf()). And if i do python -c 'print "x00 "*65+" \nr"+"x00 "*34' | xargs ./input i don't know how to pass this input to my app (./input) when it is launched via xargs

              – Alex Hoppus
              15 mins ago


















            2














            But what do you want to pass in fact? Empty quotes or empty strings? Both are valid arguments and this simple bash script can help illustrate this:



            #!/bin/bash

            printf "Argument count: %s.n" "${#@}"


            It just prints the number of arguments passed to it. I'll call it s for brevity.



            $ ./s a
            Argument count: 1.
            $ ./s a b
            Argument count: 2.
            $ ./s a b ""
            Argument count: 3.
            $ ./s a b "" ""
            Argument count: 4.
            $ ./s a b "" "" ""
            Argument count: 5.


            As you can see the empty strings are just empty strings - the quotes are removed at parsing time - and they're still valid arguments. The shell feeds them into the command. But "" can be passed on as well. It's not an empty string though. It contains two characters.



            Under the hood, for C, strings are NUL () terminated and no quotes are needed to represent them.






            share|improve this answer
























            • Mmm... Let's put it in a different way: I want pass 100 empty quotes. In C program empty quote passed as a parameter is a string which contains only 0x00. I can do it easy for one parameter like i said: ./input "" , but if i need 100 NULL parameters, it is hard to type in console ./input "" "" "" "" "" .... so i want to generate this command.

              – Alex Hoppus
              26 mins ago













            • @AlexHoppus Then you need 100 NULs and xargs: $ perl -e'print""x100' | xargs -0 ./s.

              – Tomasz
              19 mins ago











            • Okay I have already done this via xargs, but the problem is that this ./input program also have an stdin input (the program reads some values using scanf()). And if i do python -c 'print "x00 "*65+" \nr"+"x00 "*34' | xargs ./input i don't know how to pass this input to my app (./input) when it is launched via xargs

              – Alex Hoppus
              15 mins ago
















            2












            2








            2







            But what do you want to pass in fact? Empty quotes or empty strings? Both are valid arguments and this simple bash script can help illustrate this:



            #!/bin/bash

            printf "Argument count: %s.n" "${#@}"


            It just prints the number of arguments passed to it. I'll call it s for brevity.



            $ ./s a
            Argument count: 1.
            $ ./s a b
            Argument count: 2.
            $ ./s a b ""
            Argument count: 3.
            $ ./s a b "" ""
            Argument count: 4.
            $ ./s a b "" "" ""
            Argument count: 5.


            As you can see the empty strings are just empty strings - the quotes are removed at parsing time - and they're still valid arguments. The shell feeds them into the command. But "" can be passed on as well. It's not an empty string though. It contains two characters.



            Under the hood, for C, strings are NUL () terminated and no quotes are needed to represent them.






            share|improve this answer













            But what do you want to pass in fact? Empty quotes or empty strings? Both are valid arguments and this simple bash script can help illustrate this:



            #!/bin/bash

            printf "Argument count: %s.n" "${#@}"


            It just prints the number of arguments passed to it. I'll call it s for brevity.



            $ ./s a
            Argument count: 1.
            $ ./s a b
            Argument count: 2.
            $ ./s a b ""
            Argument count: 3.
            $ ./s a b "" ""
            Argument count: 4.
            $ ./s a b "" "" ""
            Argument count: 5.


            As you can see the empty strings are just empty strings - the quotes are removed at parsing time - and they're still valid arguments. The shell feeds them into the command. But "" can be passed on as well. It's not an empty string though. It contains two characters.



            Under the hood, for C, strings are NUL () terminated and no quotes are needed to represent them.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered 37 mins ago









            TomaszTomasz

            9,42852965




            9,42852965













            • Mmm... Let's put it in a different way: I want pass 100 empty quotes. In C program empty quote passed as a parameter is a string which contains only 0x00. I can do it easy for one parameter like i said: ./input "" , but if i need 100 NULL parameters, it is hard to type in console ./input "" "" "" "" "" .... so i want to generate this command.

              – Alex Hoppus
              26 mins ago













            • @AlexHoppus Then you need 100 NULs and xargs: $ perl -e'print""x100' | xargs -0 ./s.

              – Tomasz
              19 mins ago











            • Okay I have already done this via xargs, but the problem is that this ./input program also have an stdin input (the program reads some values using scanf()). And if i do python -c 'print "x00 "*65+" \nr"+"x00 "*34' | xargs ./input i don't know how to pass this input to my app (./input) when it is launched via xargs

              – Alex Hoppus
              15 mins ago





















            • Mmm... Let's put it in a different way: I want pass 100 empty quotes. In C program empty quote passed as a parameter is a string which contains only 0x00. I can do it easy for one parameter like i said: ./input "" , but if i need 100 NULL parameters, it is hard to type in console ./input "" "" "" "" "" .... so i want to generate this command.

              – Alex Hoppus
              26 mins ago













            • @AlexHoppus Then you need 100 NULs and xargs: $ perl -e'print""x100' | xargs -0 ./s.

              – Tomasz
              19 mins ago











            • Okay I have already done this via xargs, but the problem is that this ./input program also have an stdin input (the program reads some values using scanf()). And if i do python -c 'print "x00 "*65+" \nr"+"x00 "*34' | xargs ./input i don't know how to pass this input to my app (./input) when it is launched via xargs

              – Alex Hoppus
              15 mins ago



















            Mmm... Let's put it in a different way: I want pass 100 empty quotes. In C program empty quote passed as a parameter is a string which contains only 0x00. I can do it easy for one parameter like i said: ./input "" , but if i need 100 NULL parameters, it is hard to type in console ./input "" "" "" "" "" .... so i want to generate this command.

            – Alex Hoppus
            26 mins ago







            Mmm... Let's put it in a different way: I want pass 100 empty quotes. In C program empty quote passed as a parameter is a string which contains only 0x00. I can do it easy for one parameter like i said: ./input "" , but if i need 100 NULL parameters, it is hard to type in console ./input "" "" "" "" "" .... so i want to generate this command.

            – Alex Hoppus
            26 mins ago















            @AlexHoppus Then you need 100 NULs and xargs: $ perl -e'print""x100' | xargs -0 ./s.

            – Tomasz
            19 mins ago





            @AlexHoppus Then you need 100 NULs and xargs: $ perl -e'print""x100' | xargs -0 ./s.

            – Tomasz
            19 mins ago













            Okay I have already done this via xargs, but the problem is that this ./input program also have an stdin input (the program reads some values using scanf()). And if i do python -c 'print "x00 "*65+" \nr"+"x00 "*34' | xargs ./input i don't know how to pass this input to my app (./input) when it is launched via xargs

            – Alex Hoppus
            15 mins ago







            Okay I have already done this via xargs, but the problem is that this ./input program also have an stdin input (the program reads some values using scanf()). And if i do python -c 'print "x00 "*65+" \nr"+"x00 "*34' | xargs ./input i don't know how to pass this input to my app (./input) when it is launched via xargs

            – Alex Hoppus
            15 mins ago




















            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.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f496843%2fpassing-empty-string-as-program-parameter%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

            90s novel: wood nymph (similar to an otik) who becomes a scientist

            Scriptures other than the Hata Yoga Pradipika containing asanas

            De Pijp