rejetto forum

[Script] WebCam Shot

0 Members and 1 Guest are viewing this topic.

Offline Paranoia

  • Occasional poster
  • *
    • Posts: 7
    • View Profile
Hello. I have Batch script, which make shot from USB WebCamera and write it into JPG file.
And I want share this image via HFS. I add this file into HFS FileSystem, but I should "refresh image" (make shot from WebCam into this file).
How I can run Batch script from HFS when it's necessary? I mean:
  • HFS hook receive "GET /image.jpg request"
  • HFS run batch script (update this image)
  • HFS send answer (image) to browser


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13510
    • View Profile
i would try something like this
right click on the root, properties, diff template, and enter this:
Code: [Select]
[test]
{.exec|myBatchScript.}{.mime|image/jpeg.}{.load|C:\outputImage.jpg.}

of course you have to make some replacements in such text,
then you access your browser http://myaddress/~test

i cannot try it for you, sorry. Good luck.


Offline Paranoia

  • Occasional poster
  • *
    • Posts: 7
    • View Profile
Wow, thank you!
Unfortunately, there is some glitch. I can display image:
Code: [Select]
[test]
{.mime|image/jpeg.}{.load|image.jpg.}
But when I add exec command before it (notepad for test):
Code: [Select]
[test]
{.exec|notepad.}{.mime|image/jpeg.}{.load|image.jpg.}
Then I got corrupted (no image) output (in browser).
Why?


Offline LeoNeeson

  • Tireless poster
  • ****
    • Posts: 842
  • Status: On hiatus (sporadically here)
    • View Profile
    • twitter.com/LeoNeeson
Nice idea! :) Would you like to share that Batch script with us? It may be of help to any other user who want to do the same task (and we may also review it to make it work with HFS). Thank you :)
HFS in Spanish (HFS en Español) / How to compile HFS (Tutorial)
» Currently taking a break, until HFS v2.4 get his stable version.


Offline LeoNeeson

  • Tireless poster
  • ****
    • Posts: 842
  • Status: On hiatus (sporadically here)
    • View Profile
    • twitter.com/LeoNeeson
But when I add exec command before it (notepad for test):
Code: [Select]
[test]
{.exec|notepad.}{.mime|image/jpeg.}{.load|image.jpg.}
Then I got corrupted (no image) output (in browser).
Why?
I guess you have to test it with your real script (for example, "WebCamShot.vbs"), and not with the "Notepad", because the script delivers an JPEG image, and the Notepad doesn't...
HFS in Spanish (HFS en Español) / How to compile HFS (Tutorial)
» Currently taking a break, until HFS v2.4 get his stable version.


Offline Paranoia

  • Occasional poster
  • *
    • Posts: 7
    • View Profile
Ofcourse I test it with my script first (.bat). I use Notepad just for simplify code for you.
And when I test it that way:
Code: [Select]
[test]
{.exec|notepad.}{.mime|image/jpeg.}{.load|image.jpg.}
Then I ofcourse have "image.jpg" file, but it's not displayed as I said above.


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13510
    • View Profile
sorry, i forgot to specify that the exec command works in 2 ways.
The version you are using is not waiting for the program to exit, and thus you have not the result ready when "load" is executed.
To do so, you just have to write it this way:
{.exec|batchfile|out=x.}