473,385 Members | 2,028 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

regd. sending null bytes over a system command

Hi All,

I am using a python system command to execute a C++ executable file which takes certain binary input.

For example:
C++ exe name is "Test"
"Test" takes the following input . '\x02\xfa\xcbQH\x00'
command = '/opt/etc/Test %s' % ('\x02\xfa\xcbQH\x00')
system command I am using is : os.popen(command)

When this command is executed I get an error message: "TypeError: 'popen() argument 1 must be string without null bytes, not 'str'"

Is there some way I can execute this using system command without getting the above error

Thanks
Jun 17 '08 #1
1 3177
jlm699
314 100+
A way around this would be to write a temporary .sh file with the commands that you would like, and execute the file as such:
Expand|Select|Wrap|Line Numbers
  1. f = open( 'testScript.sh' )
  2. f.write( '/opt/etc/Test \x02\xfa\xcbQH\x00\n' )
  3. f.close()
  4.  
  5. os.system( 'chmod 755 ./testScript.sh' )
  6. cmdReturn = os.popen( './testScript.sh' )
  7.  
Then just check the cmdReturn for success or fail information? This is kind of a work around but there are many options for you.
Jun 18 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Danny Tuppeny | last post by:
Hi all, I'm trying to send a null character as a string delimiter through a TcpClient (code below). It's to connect to this poker bot room: http://games.cs.ualberta.ca/webgames/poker/bots.html...
1
by: Henk | last post by:
Hi, I have a problem with sending a file. I have a client application that connects to a server and sends the string "data". Then it sends a file. If the server receives "data", the method...
2
by: Fernando Barsoba | last post by:
Dear all, I have been posting about a problem trying to encrypt certain data using HMAC-SHA1 functions. I posted that my problem was solved, but unfortunately, I was being overly optimistic. I...
0
by: Lee | last post by:
Hi, I am trying to send and receive a file (it is actually an xml file, however any file may possibly be sent) using;- sending ..... public void send() {
7
by: D. Patrick | last post by:
I need to duplicate the functionality of a java applet, and how it connects to a remote server. But, I don't have the protocol information or the java source code which was written years ago. ...
9
by: Miro | last post by:
VB 2003 at the end of the code, this works great. bytCommand = Encoding.ASCII.GetBytes("testing hello send text") udpClient.Send(bytCommand, bytCommand.Length) and this recieves it Dim...
1
by: sergiotb | last post by:
Hello everyone!! I'm trying to send a image (jpg) from a C# program to a CGI perl. The problem is that the code of the client C# is not working properly...I guess. The steps to send the image are: 1)...
23
by: cmdolcet69 | last post by:
How can i add a 5ms delay between bytes i send over to a controller? I have to send 6 bytes in total however in between each byte i need to have a 5ms delay.
10
by: Markgoldin | last post by:
I am sending an XML data from not dontnet process to a .Net via socket listener. Here is a data sample: <VFPData> <serverdata> <coderun>updateFloor</coderun> <area>MD2</area>...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.