I'm new to coding and need some assistance. I am writing a python script that will go through the contents of a directory and as its walks through the directory it will send each file to a Bluetooth device.
It works fine if I specify the filename but I can’t get it to work by using the file name as a variable. Here is the code below
import os
import time
import subprocess
indir = '\\\\10.12.12.218\\myshare'
for root, dirs, filenames in os.walk(indir):
for file in filenames:
print (file)
subprocess.Popen('ussp-push /dev/rfcomm0 image1.jpg file.jpg', shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
print ('end')
I am trying to replace 'image1.jpg' in the command with the variable 'file' like below but have not been successful.
subprocess.Popen('ussp-push /dev/rfcomm0', file, 'file.jpg', shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
Will really appreciate any help.