473,657 Members | 2,486 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

pySerial- need help.

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
Jul 18 '05 #1
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
Jul 18 '05 #2
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

Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2427
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 :
0
1835
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"
2
3505
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...
7
3301
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,
8
1764
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...
3
3530
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.
2
2451
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...
2
1750
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...
1
1731
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,...
0
8392
marktang
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...
0
8305
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,...
0
8726
jinu1996
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...
1
8503
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,...
0
8603
tracyyun
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...
0
7320
agi2029
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...
0
4301
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1944
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1604
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.