Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """ Getting Value """
- import subprocess
- # Run the Bash command "ls -l" and capture the output
- output_bytes = subprocess.check_output(["ls", "-l"])
- output_str = output_bytes.decode("utf-8")
- # Print the output
- print(output_str)
- """ Just run Command """
- import subprocess
- # Run the Bash command "ls -l" and capture the output
- output = subprocess.check_output(["ls", "-l"])
- # Print the output
- print(output)
- import subprocess
- import subprocess
- # Execute the command
- result = subprocess.run(['ls', '-l'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
- # Check if the command ran successfully
- if result.returncode == 0:
- print('Command ran successfully')
- else:
- print('Command failed with return code:', result.returncode)
- print('Error message:', result.stderr.decode('utf-8'))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement