roc has asked for the wisdom of the Perl Monks concerning the following question:

hi every one...i have a cgi script to send sms as follow...

use CGI; use Device::Gsm; my $qu = new CGI; my @num = $qu->param("num"); my @msg = $qu->param("message"); print "Content-type:text/html\n\n"; my $gsm = new Device::Gsm( port => '/dev/ttyACM0', pin => '0000' , log + => 'file,network.log', loglevel => 'debug'); if( $gsm->connect() ) { #line no.14 print "connected!\n"; } else { print "sorry, no connection with gsm phone on serial port!\n"; } $gsm->register(); $gsm->send_sms( recipient => "$num[0]", content => "$msg[0]", class => 'normal');

im using frdora 12 ....when i run the script as root(su -l root -c "/usr/bin/perl /path/to/script/script.cgi") then script giving the output as "connected" in command line.. but as user(su -l user -c "/usr/bin/perl /path/to/script/script.cgi") its giving error as "Not connected at /path/to/script/script.cgi line 14" ...

the file is under 755 permission. i tried 'su -l user -c "strace -f /usr/bin/perl /path/to/script/script.cgi"'...it's giving 'open("/dev/ttyACM0", O_RDWR|O_NOCTTY|O_NONBLOCK|O_LARGEFILE) = -1 EACCES (Permission denied)....how to fix this problem...i mean how to make the script to work under user...please give me some suggestion to fix this..

------------------------------------------------

Update

hey...thanks a lot...the problem solved...i gave 777 permission to /dev/ttyacm0......then its working fine...

Replies are listed 'Best First'.
Re: GSM problem
by choroba (Cardinal) on Apr 23, 2010 at 11:51 UTC
Re: GSM problem
by almut (Canon) on Apr 23, 2010 at 11:53 UTC
    the file is under 755 permission

    What group is it?  Often, write access to a device by an unprivileged user is achieved by making the device group-writable (775 or 664) and having the user belong to that group.  (That's usually preferred to making the device world-writable (like 777 or 666).)

      hey...thanks a lot...the problem solved...i gave 777 permission to /dev/ttyacm0......then its working fine...

Re: GSM problem
by wazoox (Prior) on Apr 23, 2010 at 11:48 UTC
    Your script obviously must have write access to /dev/ttyACM0. So 755 permission is not enough, probably should be 777.
      I fear that the permission refers to the script file, not the device.