We have moved at community.getvera.com

Author Topic: Luup code for renaming a file as date and time  (Read 180 times)

Offline Wallace4793

  • Jr. Member
  • **
  • Posts: 95
  • Karma: +0/-2
Luup code for renaming a file as date and time
« on: February 24, 2019, 03:37:25 pm »
HI,

Im trying to set up a scene to capture a image from my camera on a scene execution. So far I have managed to be able to pull the image with a os.execute but im unable to get it to rename.

My basic lua is :

os.execute("wget http://192.168.0.18:9040/snapshot -P /root/nas1/foscam/")
luup.call_delay(5)
os.execute("mv snapshot $(date +%F-%H:%M).jpg")

The mv command works in ssh as standard mv command but not in my scene? Can anyone help?

Thanks

John

Offline Wallace4793

  • Jr. Member
  • **
  • Posts: 95
  • Karma: +0/-2
Re: Luup code for renaming a file as date and time
« Reply #1 on: February 24, 2019, 04:29:35 pm »
Sorry it works if I add full file path :-)

Offline akbooer

  • Beta Testers
  • Master Member
  • *****
  • Posts: 6387
  • Karma: +291/-70
  • "Less is more"
Re: Luup code for renaming a file as date and time
« Reply #2 on: February 24, 2019, 05:21:50 pm »
There is also the native Lua routine os.rename() that you could use in future.
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P, 9x Philips Hue,
Razberry, MySensors Arduino, HomeWave, AltUI, AltHue, DataYours, Grafana, openLuup, ZWay, ZeroBrane Studio.