1

Hope someone can help with this syntax error from this curl statement in python 3 running on a pi. I am using the following general format to pass a variable to a home automation controller

curl -u USER:PASSWORD http://192.xxx.x.xx/rest/vars/set/1/3/16

This is the error I get. For security purposes, I have not shown my address in the following statement from which I get the syntax error.

My username is admin and my password is test

curl-u admin:test http://192.xxx.x.xx/rest/vars/set/2/77/16
           ^

SyntaxError: invalid syntax

  • 1
    curl -u ... missing space? – SiKing Dec 9 '19 at 22:38
  • If that's the Python error (that's what it looks like) you need to show us your Python code. – Dirk Dec 10 '19 at 0:46
1

Not entirely on-topic for Raspberry Pi, but...

This question was asked in Stack Overflow, but it's rather old now. Some opined that this answer was better than the "accepted" answer. You have used the "accepted answer"; the alternative might be worth a try. Take a look at some of the other answers - you may find other ideas.

1

Just wanted to close this question. I found out today that you cannot use curl in a python program on the Pi. Instead I used "request".

I am using a rest command to push a variable in my server.

This is the replacement statement I used along with the full test program for anyone who may have the same issue.

requests.get('http://192.xxx.x.xx/rest/vars/set/2/19/45', auth=('User', 'PW'))

` import RPi.GPIO as GPIO import Adafruit_BMP.BMP085 as BMP085 import I2C_LCD_driver import time import pycurl import requests

from requests.auth import HTTPBasicAuth

pressure_sensor = BMP085.BMP085() sensor = BMP085.BMP085()

mylcd = I2C_LCD_driver.lcd() mylcd.lcd_clear() GPIO.setwarnings(False) GPIO.setmode(GPIO.BCM) GPIO.cleanup()

pressure = pressure_sensor.read_sealevel_pressure() pressure = pressure / 100.0 # 1 mbar = 100 Pa.

if pressure > 700: mylcd.lcd_display_string("Pressure: %.1f%s hPa" % (pressure,chr(32)), 3) requests.get('http://192.xxx.x.xx/rest/vars/set/2/19/45', auth=('User', 'PW')) time.sleep(20) `

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.