Reputation: 33
I wrote a simple script that can send notifications via Pushbullet using the pushbullet module, which I installed using pip. I'm using Python 2.7.14.
Now, the script works but I want to trigger it from a bash script and here starts the pain. When I use the bash script the IMPORT command fails when loading the PUSHBULLET module. I found out that also running the .py script using the syntax:
python pushbullet_test.py
fails. Can someone help me see what I'm doing wrong?
here's the bash script:
#!/bin/bash
STRING="Launching script..."
PYTHON="/usr/bin/python"
SCRIPT_ROOT="/home/ale/Documenti/"
SCRIPT="pushbullet_test.py"
echo "Using $PYTHON"
pushd .
cd $SCRIPT_ROOT
echo $STRING
$PYTHON "$SCRIPT"
popd
This is the python code:
import requests
from pushbullet import Pushbullet #THIS IS WHERE IT BREAKS
import sys
batt = "30%"
pb = Pushbullet(api_key="o.blaeudeusadushdufhsfs")
push = pb.push_note("ALERT", "Battery charge lower than {}".format(batt))
I found that the script only works when copied into the python terminal, AND when the working directory is my home. Tried to fix it using pushd but it didn't work.
Thank you for any support!
Ale
Upvotes: 1
Views: 971