Search code examples
pythonshelltty

What programming language is this? echo os.system('/bin/bash')


I found it here: https://netsec.ws/?p=337

echo os.system('/bin/bash')

os.system is from python but echo is not, I think... what language is this exactly?


Solution

  • If you looked at the echo tag, you'll see its description: "Simple function outputting text. Exists in script languages.", if you're running Linux or Mac and even Windows Command Prompt you can enter this:

    $ echo Hello shell world
    

    Output:

    Hello shell world
    

    echo is useful for testing shell glob expansion, echoing the values of environment variables and sending output to stdins of other programs, for example try this with Bash:

    $ echo 'print("Spam" * 2)' | python -
    

    Output:

    SpamSpam  
    

    And this:

    $ echo 'import os; os.system("echo SPAM")' | python -
    

    Output:

    SPAM