0

I have commands to execute in the terminal but I want to execute them directly from my python script except that my script it launches the commands on /bin /sh and my terminal on bash:

just an example :

in my script python :


!macommande

/bin/sh: macommande: command not found

while on the terminal :


[user@user] $ macommande

bash: macommande: command not found

ps : my commands work well on bash but not on /bin/sh:


!ll

/bin/sh: ll: command not found

while on the terminal :


[user@user] $ ll

rw-rw-r--  1 1614 Apr 10 16003 example
drwxrwxr-x  3 4096 Apr 10 10:13 config
drwxrwxr-x  3 4096 Apr 10 10:09 demo00

  • you can use bash to run the command by prepending /bin/bash like so: /bin/bash macommande – mkc Apr 17 at 13:14
  • This question should explain which shell /bin/sh actually is on this system, because it appears that /bin/sh is the Bourne Again shell and the underlying premise of the question is false. That error message is in the form printed by the Bourne Again shell. – JdeBP Apr 17 at 13:25
0

Because you have preceded your shell command with the exclamation point, that indicates to me that you are using Ipython. If that is true, I would recommend that you read that article: Ipython and Shell commands.

The short answer is that ‘list long’ or ‘ll’ command will work if you don’t use ‘!’ the exclamation point. I suspect that your ‘macommande’ will work also.

To enter a multi-line bash command you can use ‘%%bash’. Hope that helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.