Mar-19-2020, 05:11 PM
Hey,
Im using python3 and i have this code :
/var/tmp/tmp5qbeydbp - that this is the file that has been created and i try to run it
in the last subprocess run but i get this error:
but without it, it doesnt have permission to run.
Thanks.
Im using python3 and i have this code :
import tempfile temp_file = tempfile.mkstemp(dir="/var/tmp") with open (temp_file[1], "w+b") as tf: tf.write(result.content) tf.close() os.chmod(temp_file[1], 0o755) if 'args' in command[cmd_type]: args = [temp_file[1]] + command[cmd_type]['args'] else: args = [temp_file[1]] result = subprocess.run( args, stdout=subprocess.PIPE, universal_newlines=True, ).stdout.strip()Im creating a tempfile that is a binary file and i get this value from code:
/var/tmp/tmp5qbeydbp - that this is the file that has been created and i try to run it
in the last subprocess run but i get this error:
client_1 | File "/usr/local/lib/python3.7/subprocess.py", line 472, in run client_1 | with Popen(*popenargs, **kwargs) as process: client_1 | File "/usr/local/lib/python3.7/subprocess.py", line 775, in __init__ client_1 | restore_signals, start_new_session) client_1 | File "/usr/local/lib/python3.7/subprocess.py", line 1522, in _execute_child client_1 | raise child_exception_type(errno_num, err_msg, err_filename) client_1 | OSError: [Errno 26] Text file busy: '/var/tmp/tmp5qbeydbp'Why is file always busy ? it started when i added the chmod command.
but without it, it doesnt have permission to run.
Thanks.