R
R
Reshh4rd2018-04-03 15:00:02
Python
Reshh4rd, 2018-04-03 15:00:02

How to insert variable into subprocess?

arhiv = .....
result = subprocess.call(['tar', 'xvf' , '/home/ ??'])
The "arhiv" variable is equal to the name of the archive in the /home directory, which is parsed by date, it should be unzip.
I need instead - insert the "arhiv" variable, because the "arhiv" variable contains the file name, which is constantly changing
How to insert the arhiv variable into subprocess ? .format(arhiv) doesn't help, swears at str
python2.4
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
pcdesign, 2018-04-03
@Reshh4rd

arhiv = '/home/' + filename

result = subprocess.call(['tar', 'xvf' ,  arhiv])

T
Twelfth Doctor, 2018-04-03
@verdex

result = subprocess.call(['tar',  'xvf' ,  '/home/ ??'])

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question