Ich habe eine .sh-Datei, die ein Bild auf Raspberry Pi erzeugt. und in dieser Datei habe ich die folgenden:Get Variable Wert von .sh zu Python
Config.sh:
#!/bin/bash
suffix=$(date +%H%M%S)
cd /home/pi/photobooth_images/
sudo cp image1.jpg /usb/photobooth_images/image-${suffix}-1.jpg
sudo convert -size 1800x1200 xc:white \
image1.jpg -geometry 1536x1152+240+24 -composite \
/home/pi/template/logo.png -geometry 192x1152+24+24 -composite \
PB_${suffix}.jpg
sudo cp PB_${suffix}.jpg /usb/photobooth_montage/PB_${suffix}.jpg
sudo rm /home/pi/photobooth_images/*
returnvalue=PB_${suffix}.jpg
echo "$returnvalue"
Was ich versuche, hier zu tun ist, bekommen die PB_${suffix}.jpg
„Rueckgabewert“ Wert (Dateiname) es in Python erzeugt. Jetzt hat mein Python-Programm diese Zeile, es führt die obige .sh-Datei aus.
Main.py:
return_value = subprocess.call("sudo ./" + config.sh, shell=True)
print "The Value is: " + str(return_value) + " This value from Python"
The output I get is this
[08:33:02 04-10-2016] [PHOTO] Assembling pictures according to 1a template.
PB_083302.jpg
The Value is: 0 This value from Python
The output I am expected should be something like "PB_070638.jpg"
Jede Hilfe wird sehr geschätzt.
sollten Sie 'sudo' nicht für einfache Operationen wie diese verwenden. sudo ist für das Ausführen von Verwaltungsbefehlen reserviert. – miraculixx