Run heredoc formated script on background?
Question: I would like to know if there are any ways to run the script in heredoc format
on the background?

    
    
    #!/bin/bash
    
    python <<EOF
    import time
    time.sleep(2)
    print "AAA"
    EOF  # placing "&" here doesn't work
    
    echo "Hello"
    

I know that I can write it to a file and then run it like `python foo.py &`
but that's not the point of the question.


Answer: Just stick your `&` at the top, which is totally not intuitive, but... neither
are heredocs.

    
    
    #!/bin/bash
    
    python <<EOF &
    import time
    time.sleep(2)
    print "AAA"
    EOF 
    
    echo "Hello"
    

You can also redirect up there too:

    
    
    #!/bin/bash
    
    python <<EOF > /some/file &
    import time
    time.sleep(2)
    print "AAA"
    EOF 
    
    echo "Hello"
    

