How to execute multiple CLI commands in a python script?

Redson

I am using TeamForge's CLI to create artifacts in the Defects tracker section. The CLI file/executable is called "ctf" with no extensions. I want to use a python script to create artifacts but can only execute one command at most. I want to create a bug in one shot. This is the code I have so far:

import os
os.system("./ctf    go tracker1234;             # going to Defects section
                    create;                     # creating an artifact
                    set title This Is A Title;  # setting artifact's fields
                    set description desc123; 
                    set Product [Product 23]; 
                    set build_number Not known; 
                    set Severity Catastrophic; 
                    set steps_to_reproduce 1st comment; 
                    set Component [component 4]; 
                    set Version [version 19]; 
                    commit)                     # saving the artifact on TeamForge

Here is the error I keep getting:

sh: 1: create: not found
sh: 1: commit: not found

So I believe that these commands are not being executed sequentially or in the order that I have specified. This means that each command is being executed separately. Any suggestions to get these commands running in the order that I have specified?

Let me know if further explanation is required.

Update

I just found out that you can do this: go tracker1234 create which is two steps in one

fnl

You could try to quote your arguments to ctf; just look at this:

>>> os.system("echo hi; echo again;")
hi
again

versus:

>>> os.system("echo 'hi; echo again;'")
hi; echo again;

The semicolon terminates a command in a shell. If your arguments contain semicolons, you must quote them so they don't break your list of arguments.

However, according to the CTF guidelines, their way of handling such a situation with multiple commands seems to be putting them into a script and executing that with:

./ctf script.txt

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to execute multiple CLI commands in a python script?

From Dev

Python script to execute external commands

From Dev

How to write a python script that can get and execute python commands?

From Dev

Execute multiple sage commands from php script

From Dev

Bash script to execute multiple Unix commands

From Dev

How to execute git commands from bash script?

From Dev

How to execute the vim commands through shell script

From Dev

How to execute the following commands in a bash script?

From Dev

How to execute commands in gnuplot using shell script?

From Dev

how to execute compound commands in shell script?

From Dev

How to execute the multiple commands with && operator in new lines(not all in single line) :shell script

From Dev

How to execute sudo commands with Expect & send commands in bash script?

From Dev

How to execute multiple commands remotely on few servers?

From Dev

How to execute multiple commands in Bash, some in the background

From Dev

How can I execute a bunch of Python commands before a script is run when using the Python interpreter?

From Dev

A better way to execute multiple MySQL commands using shell script

From Dev

How do I execute a python script from the command line using custom commands?

From Dev

How to open cygwin from python script, execute commands and take data from command line in file

From Dev

How do I execute a python script from the command line using custom commands?

From Dev

How to open cygwin from python script, execute commands and take data from command line in file

From Dev

How can we open minicom from current terminal and pass multiple commands to execute and exit to 1st terminal using shell script

From Dev

How to execute python script on schedule?

From Dev

How to execute command in Python script?

From Dev

How to execute python script in Linux?

From Dev

How to execute Python script in Windows?

From Dev

Can I use a shell or python script to execute commands in a chroot?

From Dev

Running Azure-cli commands from python script

From Dev

Execute Shell Script from Python with multiple pipes

From Dev

Bash script: How to execute commands consecutively without waiting for the previous one?

Related Related

  1. 1

    How to execute multiple CLI commands in a python script?

  2. 2

    Python script to execute external commands

  3. 3

    How to write a python script that can get and execute python commands?

  4. 4

    Execute multiple sage commands from php script

  5. 5

    Bash script to execute multiple Unix commands

  6. 6

    How to execute git commands from bash script?

  7. 7

    How to execute the vim commands through shell script

  8. 8

    How to execute the following commands in a bash script?

  9. 9

    How to execute commands in gnuplot using shell script?

  10. 10

    how to execute compound commands in shell script?

  11. 11

    How to execute the multiple commands with && operator in new lines(not all in single line) :shell script

  12. 12

    How to execute sudo commands with Expect & send commands in bash script?

  13. 13

    How to execute multiple commands remotely on few servers?

  14. 14

    How to execute multiple commands in Bash, some in the background

  15. 15

    How can I execute a bunch of Python commands before a script is run when using the Python interpreter?

  16. 16

    A better way to execute multiple MySQL commands using shell script

  17. 17

    How do I execute a python script from the command line using custom commands?

  18. 18

    How to open cygwin from python script, execute commands and take data from command line in file

  19. 19

    How do I execute a python script from the command line using custom commands?

  20. 20

    How to open cygwin from python script, execute commands and take data from command line in file

  21. 21

    How can we open minicom from current terminal and pass multiple commands to execute and exit to 1st terminal using shell script

  22. 22

    How to execute python script on schedule?

  23. 23

    How to execute command in Python script?

  24. 24

    How to execute python script in Linux?

  25. 25

    How to execute Python script in Windows?

  26. 26

    Can I use a shell or python script to execute commands in a chroot?

  27. 27

    Running Azure-cli commands from python script

  28. 28

    Execute Shell Script from Python with multiple pipes

  29. 29

    Bash script: How to execute commands consecutively without waiting for the previous one?

HotTag

Archive