...

View Full Version : Question on cgi access to server apps



DrStrangeLv
05-15-2009, 06:19 PM
I have a cgi script to control my dslr camera
On my server the app that sends commands to the camera is gphoto2
Running under Debian on a Linksys NSLU2.
I'm using tthtp and pearl.

My problem is that I'm not able to get the cgi to send the command to the server.

I'm no expert on cgi.

What I need to know is what cgi command can pass the server command.

Thank you
Jim

KevinADC
05-15-2009, 10:49 PM
system(commands)
qx{commands}

DrStrangeLv
05-16-2009, 12:33 AM
Do I need to somehow login to server as a user or can I do straight from the script?

KevinADC
05-16-2009, 08:05 PM
Do I need to somehow login to server as a user or can I do straight from the script?

Those are perl functions or commands, so you use them in a perl script. Look them up online or in your local install of perl.

http://perldoc.perl.org/

DrStrangeLv
05-19-2009, 04:26 AM
OK all well and good to provide the link thank you, however I still can not get it to work.
Please see details below I'm truly in need of getting this to work and any help would be great thank you.

Jim

Here is a more detail explanation:
When login using putty under ssh to server as root
This command works fine

gphoto2 --set-config capture=on --set-config capturetarget=1 --set-config capture=on --set-config eos-shutterspeed=35 --set-config eos-iso=0 --set-config capture=off --capture-image

But when I attempt it from within a cgi script using this command
system("gphoto2 --set-config capture=on --set-config capturetarget=1 --set-config capture=on --set-config eos-shutterspeed=35 --set-config eos-iso=0 --set-config capture=off --capture-image");

I get this error back

*** Error *** An error occurred in the io-library ('Could not claim the USB device'): Could not claim interface 0 (Operation not permitted). Make sure no other program or kernel module (such as sdc2xx, stv680, spca50x) is using the device and you have read/write access to the device. *** Error *** An error occurred in the io-library ('Could not claim the USB device'): Could not claim interface 0 (Operation not permitted). Make sure no other program or kernel module (such as sdc2xx, stv680, spca50x) is using the device and you have read/write access to the device. *** Error *** An error occurred in the io-library ('Could not claim the USB device'): Could not claim interface 0 (Operation not permitted). Make sure no other program or kernel module (such as sdc2xx, stv680, spca50x) is using the device and you have read/write access to the device. *** Error *** An error occurred in the io-library ('Could not claim the USB device'): Could not claim interface 0 (Operation not permitted). Make sure no other program or kernel module (such as sdc2xx, stv680, spca50x) is using the device and you have read/write access to the device. *** Error *** An error occurred in the io-library ('Could not claim the USB device'): Could not claim interface 0 (Operation not permitted). Make sure no other program or kernel module (such as sdc2xx, stv680, spca50x) is using the device and you have read/write access to the device. *** Error *** An error occurred in the io-library ('Could not claim the USB device'): Could not claim interface 0 (Operation not permitted). Make sure no other program or kernel module (such as sdc2xx, stv680, spca50x) is using the device and you have read/write access to the device. *** Error *** An error occurred in the io-library ('Could not claim the USB device'): Could not claim interface 0 (Operation not permitted). Make sure no other program or kernel module (such as sdc2xx, stv680, spca50x) is using the device and you have read/write access to the device. ERROR: Could not capture. *** Error (-53: 'Could not claim the USB device') *** For debugging messages, please use the --debug option. Debugging messages may help finding a solution to your problem. If you intend to send any error or debug messages to the gphoto developer mailing list , please run gphoto2 as follows: env LANG=C gphoto2 --debug --debug-logfile=my-logfile.txt --set-config capture=on --set-config capturetarget=1 --set-config capture=on --set-config eos-shutterspeed=35 --set-config eos-iso=0 --set-config capture=off --capture-image Please make sure there is sufficient quoting around the arguments.

KevinADC
05-19-2009, 06:51 AM
Sorry, I have no idea what those errors are about.

Shannon Blonk
05-19-2009, 04:45 PM
It sounds like the account the cgi is running under doesn't have permission to access the camera.

Use lsusb to find out the bus-id and device-id of the camera, then check permissions (both as yourself and through the cgi) with ls. Something like

ls -l /dev/bus/usb/{bus-id}/{device-id}

or

ls -l proc/usb/{bus-id}/{device-id}

You and the cgi want read-write permission.

DrStrangeLv
05-20-2009, 03:36 PM
Thank you Shannon I'll check that.

DrStrangeLv
05-20-2009, 03:41 PM
I need no security on this as it is a stand alone box
Can I use sudo and if so how do I apply it and run from cgi?

Shannon Blonk
05-20-2009, 05:35 PM
Try chmod 0666 on the camera to make it world read/write.

If that doesn't work, try editing the sudoers file with

sudo sudoedit /etc/sudoers

and add the line

cgi-username-here ALL = NOPASSWD: /full/path/to/gphoto2

then in your cgi try

system("sudo gphoto2 ...

DrStrangeLv
05-21-2009, 03:23 AM
Issued solved thankyou kindly



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum