RE: [PHP] read from comport: windows vs. linux
-Original Message- From: Richard Lynch [mailto:[EMAIL PROTECTED] Sent: Thursday, April 07, 2005 6:18 AM [EMAIL PROTECTED] dev]# ls -al ttyS* crw-rw-rw- 1 apache apache 4, 64 Apr 5 16:01 ttyS0 This is not an acceptable solution anyway, the permissions are changed on a reboot: Crw-rw 1 root uucp 4, 64 Apr 7 09:56 /dev/ttyS0 instead I´ve added the apache user to the group uucp in /etc/groups But I did check the permissions on the /dev and only root could write to that, that´s changed now. Just for fun... On the command line, su to 'apache' and then do cat /dev/ttyS0 Apache user has /sbin/nologin and no bash, so I used a chsh apache, added /bin/bash and had no problem catting the device... Okay, if that works, run your PHP script from the command line, as apache. I´m not running PHP as CGI Report it as a bug, I guess. http://bugs.php.net Nah, it´s not a PHP bug, cause I can read from it when using fopen(/dev/ttyS0, r); I´m on my way... think it´s now oddies with the script, that was developed on a windows platform, you know things like fwrite($fp, sh ssh\r\n); *MAYBE* you could try using http://php.net/exec (with cat /dev/ttyS0) and see if that allows you any kind of access. Doubt it, though. I´m using exec to set the comport speed and the likes. -- Med venlig hilsen / best regards ComX Networks A/S Kim Madsen Systemudvikler/systemdeveloper -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] read from comport: windows vs. linux
-Original Message- From: Jay Blanchard [mailto:[EMAIL PROTECTED] Sent: Tuesday, April 05, 2005 3:42 PM having apache be the groupowner doesn´t change anything You may also need to change the user/owner, depending on what Apache is running as. User and group is apache. It made _no_ difference at all, I´m still getting permission denied, when calling fopen :-/ [EMAIL PROTECTED] dev]# ls -al ttyS* crw-rw-rw- 1 apache apache 4, 64 Apr 5 16:01 ttyS0 -- Med venlig hilsen / best regards ComX Networks A/S Kim Madsen Systemudvikler/systemdeveloper -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] read from comport: windows vs. linux
On Wednesday 06 April 2005 14:41, Kim Madsen wrote: User and group is apache. It made _no_ difference at all, I´m still getting permission denied, when calling fopen :-/ [EMAIL PROTECTED] dev]# ls -al ttyS* crw-rw-rw- 1 apache apache 4, 64 Apr 5 16:01 ttyS0 Well if other has rw then it doesn't really matter who owns the file. What does the php error log say? Are any of the safe mode stuff enabled? Are you running SELinux? Anyway the following works for me: error_reporting(E_ALL); //error_reporting(0); ini_set('display_errors', TRUE); if (!$fp = fopen(/dev/ttyS0, 'w+b')) { echo \nError! Could not open COMport - Got a terminal open?\n; exit; } else { $i = 0; while ((false !== ($char = fgetc($fp))) AND $i 10) { $i++; echo $i::[$char]br; } echo $i; } -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- New Year Resolution: Ignore top posted posts -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] read from comport: windows vs. linux
-Original Message- From: Jason Wong [mailto:[EMAIL PROTECTED] Sent: Wednesday, April 06, 2005 9:36 AM Well if other has rw then it doesn't really matter who owns the file. My point exactly! What does the php error log say? Samething as on the site: Apr 6 10:16:12 lager httpd: PHP Warning: fopen(/dev/ttyS0): failed to open stream: Permission denied in /var/www/html/s.php on line 85 Are any of the safe mode stuff enabled? Nops, disabled, cause I use exec() to set the comport speed, parity, stopbits and so... Are you running SELinux? Jeps, that´s installed, but I have no clue, what that is and do. The server with the problem runs Feodora 3, I´m running RH9 on my own servers. -- Med venlig hilsen / best regards ComX Networks A/S Kim Madsen Systemudvikler/systemdeveloper -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] read from comport: windows vs. linux
Kim Madsen wrote: -Original Message- From: Jason Wong [mailto:[EMAIL PROTECTED] Sent: Wednesday, April 06, 2005 9:36 AM Well if other has rw then it doesn't really matter who owns the file. My point exactly! What does the php error log say? Samething as on the site: Apr 6 10:16:12 lager httpd: PHP Warning: fopen(/dev/ttyS0): failed to open stream: Permission denied in /var/www/html/s.php on line 85 Are any of the safe mode stuff enabled? Are you running mod_security? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] read from comport: windows vs. linux
-Original Message- From: Burhan Khalid [mailto:[EMAIL PROTECTED] Sent: Wednesday, April 06, 2005 10:43 AM Are you running mod_security? Nops: [EMAIL PROTECTED] ~]# httpd -l Compiled in modules: core.c prefork.c http_core.c And SELinux is now disabled, still no change... :-/ /Kim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] read from comport: windows vs. linux
On Wednesday 06 April 2005 16:18, Kim Madsen wrote: Are you running SELinux? Jeps, that?s installed, but I have no clue, what that is and do. The server with the problem runs Feodora 3, I?m running RH9 on my own servers. Check the archives, there have been a lot of people having problems with having SELinux enabled and were resolved when it was disabled. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- New Year Resolution: Ignore top posted posts -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] read from comport: windows vs. linux
On Tue, April 5, 2005 11:41 pm, Kim Madsen said: -Original Message- From: Jay Blanchard [mailto:[EMAIL PROTECTED] Sent: Tuesday, April 05, 2005 3:42 PM having apache be the groupowner doesn´t change anything You may also need to change the user/owner, depending on what Apache is running as. User and group is apache. It made _no_ difference at all, I´m still getting permission denied, when calling fopen :-/ [EMAIL PROTECTED] dev]# ls -al ttyS* crw-rw-rw- 1 apache apache 4, 64 Apr 5 16:01 ttyS0 Just for fun... On the command line, su to 'apache' and then do cat /dev/ttyS0 Okay, if that works, run your PHP script from the command line, as apache. If *THAT* works, then I got nothin' Report it as a bug, I guess. http://bugs.php.net Though it's possible that the OS requires a shell to exist for you to open /dev/ttyS0... *MAYBE* you could try using http://php.net/exec (with cat /dev/ttyS0) and see if that allows you any kind of access. Doubt it, though. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] read from comport: windows vs. linux
[snip] I´ve got a problem porting from windows to Linux, when I wanna read and write to the serial port. This works like a charm in windows: if (!$fp = fopen(COM1, 'w+b')) { echo \nError! Could not open COMport - Got a terminal open?\n; exit; } The program continues, but breaks in linux: if (!$fp = fopen(/dev/ttyS0, 'w+b')) { echo \nError! Could not open COMport - Got a terminal open?\n; exit; } I´ve checked and made sure that there´s a device on /dev/ttyS0 with minicom, where I´ve got no problem accessing the device. But I keep getting this error: Warning: fopen(/dev/ttyS0): failed to open stream: Permission denied in /var/www/html/s.php on line 85 Line 85 is the fopen line. Permissions are: crw-rw-rw- 1 root uucp 4, 64 Apr 5 13:38 /dev/ttyS0 having apache be the groupowner doesn´t change anything [/snip] You may also need to change the user/owner, depending on what Apache is running as. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php