I meet a problem about system function. If I run
echo -e '\x2f'
int main(int argc, char* argv, char** envp)
printf("The command is :%s\n",argv);
system( argv );
The command is :echo -e '\x2f'
# I used \\ because python will transfer \x2f to / automatially
command="echo -e '\\x2f'"
echo command can output differently between
bash -c "echo -e '\x2f'" # Output : / sh -c "echo -e '\x2f'" # Output : -e /
In order to have Python spit out the same, something like below should work.
(For your reference, included the same implementation with subprocess)
import os import subprocess command = "echo -e '\\x2f'" os.system( command ) # Output : -e / subprocess.call( command , shell=True ) # Output : -e / bashcmd = "bash -c \"echo -e '\x2f'\"" os.system( bashcmd ) # Output : / subprocess.call( bashcmd , shell=True ) # Output : /
I am uncertain of how you got
-e \x2f as your output though.