How to pass non-keyboard characters as the argument of the called program for the Windows and Linux platforms from the command line?

Example:

./programm 123 456 "ΠΊΠ°ΠΊΠΈΠ΅-Ρ‚ΠΎ-Π½Π΅Π½Π°Π±ΠΈΡ€Π°Π΅ΠΌΡ‹Π΅-символы: Π½Π°ΠΏΡ€ΠΈΠΌΠ΅Ρ€ \x1\x0\x3" 

I tried to screen it in different ways with the help of "", "", ``, but the results did not bring these manipulations. Used \ 0, but just 0 was entered into the program.

Added by:

Through Python, I managed to start with the necessary parameters, but I found out for myself that it is impossible to transmit a null character, it swears. But still, how to do it through the console?

  • And which program do you transfer these parameters to? maybe she "does not want to accept them"? - KoVadim
  • @KoVadim, #include <iostream> int main(int argc, char **argv){ for(int i=0; i<argc;++i) std::cout<<argv[i]<<"\n"; return 0;} #include <iostream> int main(int argc, char **argv){ for(int i=0; i<argc;++i) std::cout<<argv[i]<<"\n"; return 0;} - borat_brata
  • one
    transmitting a null character directly will be very difficult - the fact is that the null character is used as a sign of a line ending Therefore, if your program needs to receive non-printable characters, make your "protocol". - KoVadim
  • @KoVadim, Just thought about it, that you cannot pass a null character for a set of pointers to char *. The thought was confirmed, but did not figure it out with the console. - borat_brata
  • If a null character is very much needed - then pass it as '\ 0', and then make a replacement in the code. Just remember that you will need to separately remember the length of the buffer. - KoVadim

1 answer 1

In Bash, use Ansi-C Quoting in the form of $'...' .

Words of the form $ 'string' are treated specially. The word expands to string, with ANSI C standard.

Inside single quotes, all \nn ( escape sequences ) will be replaced before passing the full sequence of characters as an argument.

 $ echo $'aaa\x1\x2\x3'|xd 000000 61 61 61 01 02 03 0a >aaa....< 

The example in question will look like this:

 ./programm 123 456 $'\x1\x0\x3'