Hi all,
I try to invoke python serial script via my browser using PHP (exec
function). For the serial communication, i used pySerial module. It
fine when it run it as root but when i try to run it from browser, i
got this error in my httpd/error_log
File "weather1.p y", line 9, in ?
ser=serial.Seri al('/dev/ttyS0',9600,tim eout=1)
File "/usr/lib/python2.3/site-packages/serial/serialutil.py", line
153, in __init__
self.open()
File "/usr/lib/python2.3/site-packages/serial/serialposix.py" , line
137, in open
raise SerialException ("Could not open port: %s" % msg)
serial.serialut il.SerialExcept ion: Could not open port: [Errno 13]
Permission denied: '/dev/ttyS0'
i tried chmod go+wr /dev/ttyS0 but i still got the error.
BTW, i used apache 2.0.52, PHP 4.3.10 and Fedora Core 3
Thanks in advance.
--
regards,
kamarudin samsudin 2 4121
kamarudin samsudin wrote: Hi all,
I try to invoke python serial script via my browser using PHP (exec function). For the serial communication, i used pySerial module. It fine when it run it as root but when i try to run it from browser, i got this error in my httpd/error_log
File "weather1.p y", line 9, in ? ser=serial.Seri al('/dev/ttyS0',9600,tim eout=1) File "/usr/lib/python2.3/site-packages/serial/serialutil.py", line 153, in __init__ self.open() File "/usr/lib/python2.3/site-packages/serial/serialposix.py" , line 137, in open raise SerialException ("Could not open port: %s" % msg) serial.serialut il.SerialExcept ion: Could not open port: [Errno 13] Permission denied: '/dev/ttyS0'
i tried chmod go+wr /dev/ttyS0 but i still got the error.
BTW, i used apache 2.0.52, PHP 4.3.10 and Fedora Core 3
Thanks in advance.
This sounds more like a linux problem rather than a python problem.
Modern linux'es set the permissions in /etc/security files, and these
will override any chmod that you do in the /dev/ directory. What you
need to do is edit /etc/security/console.perms file.
In Mandrake I have the following lines:
------------------------------------------------
<serial>=/dev/ttyS* /dev/rfcomm* /dev/ircomm*
---and lower down ---
<console> 0660 <serial> 0660 root.uucp
------------------------------------------------
You can change the <console> / <serial> line so that you have 666
permissions, but it would probably be better to ensure that the serial
is assigned a non-root group (uucp in my case), change the group of your
script to match, set the sgid bit on your program and change the execute
permissions on your script so everyone can use it.
chmod 2755 <script>
This way your script will execute as group uucp, and theoretically it
should have permission to access the /dev/ttyS* devices.
Hope that helps,
Joal
Joal Heagney wrote: kamarudin samsudin wrote:
Hi all,
I try to invoke python serial script via my browser using PHP (exec function). For the serial communication, i used pySerial module. It fine when it run it as root but when i try to run it from browser, i got this error in my httpd/error_log
File "weather1.p y", line 9, in ? ser=serial.Seri al('/dev/ttyS0',9600,tim eout=1) File "/usr/lib/python2.3/site-packages/serial/serialutil.py", line 153, in __init__ self.open() File "/usr/lib/python2.3/site-packages/serial/serialposix.py" , line 137, in open raise SerialException ("Could not open port: %s" % msg) serial.serialut il.SerialExcept ion: Could not open port: [Errno 13] Permission denied: '/dev/ttyS0'
i tried chmod go+wr /dev/ttyS0 but i still got the error.
BTW, i used apache 2.0.52, PHP 4.3.10 and Fedora Core 3 Thanks in advance. This sounds more like a linux problem rather than a python problem. Modern linux'es set the permissions in /etc/security files, and these will override any chmod that you do in the /dev/ directory. What you need to do is edit /etc/security/console.perms file.
In Mandrake I have the following lines:
------------------------------------------------ <serial>=/dev/ttyS* /dev/rfcomm* /dev/ircomm* ---and lower down --- <console> 0660 <serial> 0660 root.uucp ------------------------------------------------ You can change the <console> / <serial> line so that you have 666 permissions, but it would probably be better to ensure that the serial is assigned a non-root group (uucp in my case), change the group of your script to match, set the sgid bit on your program and change the execute permissions on your script so everyone can use it.
*sigh*
su to root first.
chown root.uucp <script>
(Assuming you're going to install this as a root binary.)
chmod 2755 <script>
This way your script will execute as group uucp, and theoretically it should have permission to access the /dev/ttyS* devices.
Hope that helps,
Joal This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Gregory Nans |
last post by:
hello,
i need some help to 'tree-ify' a string...
for example i have strings such as :
s = """A(here 's , B(A ) silly test) C(to show D(what kind) of stuff i
need))"""
and i need to parse them to have a tree representation such as :
|
by: xunling |
last post by:
i have a question about answering ..... this topic is "need help"
what do i have to write at te topic line, !after i have klicked the
"answer message" button
ive tried many possibilities, all dont work
"Re:" need help
"Re:need help"
|
by: Paul Mendez |
last post by:
I really need some help
Date Code ConCAT Bal_Fwd NS_Fees Amt_Coll Cur_End_Bal
1/15/2004 KW 11KW2003 $500.00 $250.00 $250.00
2/15/2004 KW 12KW2003 $300.00 $500.00 -$200.00
3/15/2004 KW 1KW2004 ???? $123.00 $584.00 -$461.00
4/15/2001 KW 2KW2004 XXXX $223.00 $484.00 -$261.00
1/15/2004 SO 11O2003 $300.00 $250.00 $50.00
2/15/2004 SO 12SO2003 $300.00 $500.00 -$200.00...
|
by: Timothy Shih |
last post by:
Hi, I am trying to figure out how to use unmanaged code using P/Invoke. I
wrote a simple function which takes in 2 buffers (one a byte buffer, one a
char buffer) and copies the contents of the byte buffer into the character
pointer. The code looks like the following:
#include <stdio.h>
#include <stdlib.h>
#include "stdafx.h"
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
|
by: Elliot M. Rodriguez |
last post by:
I am having a heckuva time debugging this, or determining why my page is
behaving this way.
I have a search form, that when completed, returns a datagrid. When the user
selects a row (normal selectcommand button), i assign some session variables
and perform a rediect to a "more information" page. Neither page is using
Output Caching.
On the more information page, a button reads "new search". this clears the
session variables i set in...
| |
by: Rich Squid |
last post by:
Hello
Here's my basic problem:
On my asp.net form page I have a DetailsView (default mode=edit) bound
to a AccessDataSource control. Users can successfuly update a databound
template field, but I wanted to add a custom validator to check that
the account number they are entering exists in a table in the Access
Database.
|
by: XML Beginner |
last post by:
I have an XML file that contains values that my application needs, so it
knows which database to connect to. It also contains a configuration option
so that I can specify which node to return values from. For example, the XML
file is meant to return the values from node"config2", because the
"configoption" node's value is that.
I'm extremely new to XML and the code that accesses it, but from what I
could gather from materials read, I got...
|
by: =?Utf-8?B?am9lb2ppaA==?= |
last post by:
Most students do not have enough time to do their homeworks, assignments,
college papers, etc alone. Also most of them, even though they know what to
do with respect to their writing assignment, find it very hard to overcome
the inertia and hence can't just get started. Besides, Maths problems are
always a source of worries and nightmares to the majority of students. Hence
most students need an academic mentor who can help them...
|
by: jhaydon |
last post by:
First of all, I'm not a CSS expert. If I was, I wouldn't need to be posting for help here. Secondly, I have been doing web design for several years, just not css. Thirdly, I need help and hope someone who knows how to help a person without making them feel like they are a complete idiot can help me.
I need to know how to code a nav/menu bar (or whatever you want to call it) in a css template so that it works in IE. It works in Firefox,...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |