How to run a command out of a specific directory

Hi, python has command that servers a folder. To run it you enter "python -m simpleHTTPServer 8000" without the "" in the directory of the files you would like to be able to access. Then enter your ip address followed by:8000 and it shows you the content of the folder and you can download the files. You have to set your router to port forward it first.

If I ssh with putty, then cd to the directory I want (/mnt/sd/arduino) and run the command, it works. I would like to have my sketch run it automatically. I tried this, and it did not seem to work:

Process StartWebServer;
StartWebServer.runShellCommand(F("/mnt/sd/arduino/python -m simpleHTTPServer 8000"));

I tried this to,

Process StartWebServer;
StartWebServer.runShellCommand(F("python -m simpleHTTPServer 8000"));

and this:

Process StartWebServer;
StartWebServer.runShellCommand(F("python /mnt/sd/arduino/-m simpleHTTPServer 8000"));

and this:

Process StartWebServer;
StartWebServer.runShellCommand(F("cd /mnt/sd/arduino"));
StartWebServer.runShellCommand(F("python -m simpleHTTPServer 8000"));

but nothing seemed to work. How to I run the command, making sure it is run out of a specific directory?

Thanks!

Can you post the entire code?

I think the last combination is the best solution, try with runShellCommandAsynchronously when you launch the python command, not the cd command.

Second idea, when you run the two commands separately, the second command does not depend from the first. So you have to launch both commands together.

You can launch them in this way

StartWebServer.runShellCommandAsynchronously(F("cd /mnt/sd/arduino/ && python -m simpleHTTPServer 8000"));

Or you can create a shell script that launches these two commands and then run the script from the sketch.