/usr/local/bin/dbsdm &
this is what I have given in rc.local
where dbsdm is a python script
## ----------------- start of code -------------
#!/usr/bin/env python
import socket
import commands
dct_error = {500:"Command not found in server"}
try:
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.bind(('', 8881))
sock.listen(5)
except:
print "May be server Already Running or a Socket Error"
exit
# loop waiting for connections
# terminate with Ctrl-Break on Win32, Ctrl-C on Unix
try:
while True:
newSocket, address = sock.accept()
# print "Connected from", address
receivedData = newSocket.recv(8192)
if not receivedData.strip():
newSocket.close()
continue
if receivedData.startswith('dbs'):
print 'CMD :',receivedData
receivedData = "/usr/local/bin/"+receivedData
(status,out_put) = commands.getstatusoutput(receivedData)
if status == 0:
if out_put.strip():
newSocket.sendall(out_put)
else:
newSocket.sendall('No data available')
else:
newSocket.sendall(dct_error[500])
newSocket.close()
# print "Disconnected from", address
except:
sock.close()
else:
sock.close()
## ----------------- End of code -------------
[email protected]
9995998205
www.linux-minds.blogspot.com
On 12 February 2010 14:41, Hrishikesh Murali
<[email protected]>wrote:
> Hi,
>
> On Fri, Feb 12, 2010 at 1:41 PM, BR!j!TH <[email protected]> wrote:
>
>> I have created a client server scripts in python. The server script is to
>> be run background in a system all the time..
>> So I decided to put it in rc.local. But its not working. I don't know why
>> ..?
>> An interesting thing is the script that I added in rc.local in running but
>> it is not working in desired why ...
>> But when I run the script manually in a terminal its working flawlessly...
>>
>>
>
> Is this program you are running independent or does it depend on some other
> files also?
>
> Can you mention what is the command you are running in rc.local?
>
> The reason I am saying this is because when the script in rc.local is
> called, it runs under the '/' directory and this might be the error, that is
> the program is running but not as desired.
>
> If it not independent, then I suggest you give the full path of the files
> which the server script depends on.
>
> --
> Thanks and Regards,
> Hrishikesh Murali
>
> --
> ubuntu-in mailing list
> [email protected]
> https://lists.ubuntu.com/mailman/listinfo/ubuntu-in
>
>
--
ubuntu-in mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-in