I want to execute a python program on a remote server, without creating a script. The remote server does not allow me to create any files anywhere on the file system.
The python program has following structure, though the functions are a lot more complicated
def test2(): print("test2") def test_func(): test2() print("test_func") test_func()
Is there a way to execute this program directly from command line?
I have tried these 2 approaches
- Pass the code using python -c option.
- Launch python interactive mode, and copy paste the code to run.
I get errors in both the cases. However, any code without user defined functions is able to execute with 2nd approach. Is it possible to get the code above working without creating a local script?