I've used twisted to make an SSH server similar to the one shown here. I attempted to add curl functionality to it like so:
class CurlProcessProtocol(protocol.ProcessProtocol):
def connectionMade(self):
self.transport.closeStdin()
def do_curl(self, *args):
"Sets up a download"
curlProcess = CurlProcessProtocol()
args = tuple(['curl'])+args
reactor.spawnProcess(curlProcess, 'curl', args)
I have the files necessary for curl to run in the same directory as my program. When I connect to the SSH server and attempt a curl command, I get the following error: Error: (2, 'CreateProcess', 'The system cannot find the file specified.')
I tried appending os.getcwd()+
before 'curl'
to no avail.
Alright, so I needed to be more specific. Here is a working do_curl. I had to add a "\" after getcwd() and a ".exe" after curl.
def do_curl(self, *args):
"Sets up a download"
curlProcess = CurlProcessProtocol()
args = tuple([os.getcwd()+'\curl.exe'])+args
reactor.spawnProcess(curlProcess, os.getcwd()+'\curl.exe', args)