I'm trying to run this code:
import subprocess
def install_curl():
result = subprocess.check_output(['command', '-v', 'dnf']) #
if not result:
print("You should Install curl")
else:
result = subprocess.check_output(['command', '-v', 'apt'])
print(result)
install_curl()
Then I'm getting this error:
Traceback (most recent call last):
File "/home/pbravodez1/projects/Automate_task/test_gpg.py", line 98, in <module>
install_curl()
File "/home/pbravodez1/projects/Automate_task/test_gpg.py", line 91, in install_curl
result = subprocess.check_output(['command', '-v', 'dnf']) #
File "/usr/lib/python3.8/subprocess.py", line 411, in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
File "/usr/lib/python3.8/subprocess.py", line 489, in run
with Popen(*popenargs, **kwargs) as process:
File "/usr/lib/python3.8/subprocess.py", line 854, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/lib/python3.8/subprocess.py", line 1702, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'command'
Do you have any idea on how to run this "command" in order to check which package manager is installed in the Operating System?