Sponsored Content
Top Forums Shell Programming and Scripting [python]string to list conversion Post 302572448 by animesharma on Thursday 10th of November 2011 04:01:17 AM
Old 11-10-2011
[python]string to list conversion

I have a file command.txt. It's content are as follows:-
Quote:
scriptname -arg1 aa -test -arg2 bb
The content of file is actually a command with script name and respective arguments.
arg1 and arg2 are dummy arguments , format : -arg arg_value
test is a argument specifying run mode , format : -arg

In my python code, i read it and store it in a variable named "data"

Code:
fin = open(command.txt, "rb")
data = fin.read()
fin.close()

Now i need your help on how should I process "data" to get the scriptname, arg1, run_mode,arg2.
I was trying to convert the "data" into a list and then read values from it using if-else(case) statements.

However- since i am new in python- i am not able to convert data into list, probably the content are not suitable for such conversion.

Please Help!!!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

String Conversion in awk

I am porting a awk script from Windows to unix I_SALE_MEDIA=$67 if ((I_VOID_FLAG == "Y") && (I_SALE_MEDIA == 0)) NOW consider the case where I_SALE_MEDIA i.e $67 is "000" The above comparison works fine in Windows , but to make it work in Unix , I had to change the above as follows : ... (3 Replies)
Discussion started by: rohanrege
3 Replies

2. Programming

C String manipulation/conversion help

Hi, I need to be able to take an unsigned long value and convert it to a string that is separted by commas. So for example, if i have the unsigned long value 1372516, I'm supposed to somehow get "1,372,516". Can someone please give me the right direction to go about doing this? Thanks. (3 Replies)
Discussion started by: Yifan_Guo
3 Replies

3. Shell Programming and Scripting

Code conversion from JSP to PYTHON

Guys I need to convert a code from JSP (Java Tags are also there inside JSP) to PYTHON. I have OK kind of knowledge in PYTHON, but dont have a muck knowledge in JAVA/JSP. Any idea how to approach? Thanks in advance to all C Saha (1 Reply)
Discussion started by: csaha
1 Replies

4. Programming

Hex string conversion?

Hello all. I need help... How can I cenvert this 42ec93df826c804ea531c56594db453d54daad4b to normal text? What convertor I have to use? Thanks. (12 Replies)
Discussion started by: escudo
12 Replies

5. Shell Programming and Scripting

conversion of code in perl and python

How to convert below bash code in perl and python. for BLOCK in /sys/block/emcpow* do echo "100000" > "$BLOCK"/queue/nr_requests echo "noop" > "$BLOCK"/queue/scheduler done (2 Replies)
Discussion started by: learnbash
2 Replies

6. Shell Programming and Scripting

String to HEX conversion in UNIX

i have this below string which i need to convert it to HEX. i have already tried it but it showing extra few things on it.. let me show what i have done and what is the output i am getting and what is the desired output the input string is "!\"\"\"\"\"\"\"!\"\"\"\"\"\"\"" which is... (4 Replies)
Discussion started by: vivek d r
4 Replies

7. Shell Programming and Scripting

String to Date conversion

Hi, I have a String say 20131224 which represents a date. I want to to subtract 1 day from this. Any idea how can i do this on AIX. (1 Reply)
Discussion started by: RahulM
1 Replies

8. Programming

Python conversion to epoch time

Hi. I have timestamps that I am trying to convert to epoch time. An example: I am trying to convert this to an epoch timestamp but have one little glitch. I have this: import time date_time = '' pattern = '' epoch = int(time.mktime(time.strptime(date_time, pattern))) print epoch... (1 Reply)
Discussion started by: treesloth
1 Replies

9. Shell Programming and Scripting

Python concat list with a string variable

Hello! #!/usr/bin/env python hn = "simsa-svr" for container in containerslist: Name = container I want to print Name along with hn i,e simsa-svr. I tried like Name = container'-'.join(hn) did not work. Needed result: lilly2232321-simsa-svr (2 Replies)
Discussion started by: ashokvpp
2 Replies

10. Shell Programming and Scripting

Python soap and string to .xlsx conversion

Hi experts - I'm relatively new to python, but I have an requirement to automate getting a file from a WebLib server using an API. The file I'm requesting from this sever is an excel spreadsheet (.xlsx). I get a valid response back via an xml doc from the server. In this xml file I get... (8 Replies)
Discussion started by: timj123
8 Replies
QNetworkOperation(3qt)													    QNetworkOperation(3qt)

NAME
QNetworkOperation - Common operations for network protocols SYNOPSIS
#include <qnetworkprotocol.h> Inherits QObject. Public Members QNetworkOperation ( QNetworkProtocol::Operation operation, const QString & arg0, const QString & arg1, const QString & arg2 ) QNetworkOperation ( QNetworkProtocol::Operation operation, const QByteArray & arg0, const QByteArray & arg1, const QByteArray & arg2 ) ~QNetworkOperation () void setState ( QNetworkProtocol::State state ) void setProtocolDetail ( const QString & detail ) void setErrorCode ( int ec ) void setArg ( int num, const QString & arg ) void setRawArg ( int num, const QByteArray & arg ) QNetworkProtocol::Operation operation () const QNetworkProtocol::State state () const QString arg ( int num ) const QByteArray rawArg ( int num ) const QString protocolDetail () const int errorCode () const void free () DESCRIPTION
The QNetworkOperation class provides common operations for network protocols. An object is created to describe the operation and the current state for each operation that a network protocol should process. For a detailed description of the Qt Network Architecture and how to implement and use network protocols in Qt, see the Qt Network Documentation. See also QNetworkProtocol and Input/Output and Networking. MEMBER FUNCTION DOCUMENTATION
QNetworkOperation::QNetworkOperation ( QNetworkProtocol::Operation operation, const QString & arg0, const QString & arg1, const QString & arg2 ) Constructs a network operation object. operation is the type of the operation, and arg0, arg1 and arg2 are the first three arguments of the operation. The state is initialized to QNetworkProtocol::StWaiting. See also QNetworkProtocol::Operation and QNetworkProtocol::State. QNetworkOperation::QNetworkOperation ( QNetworkProtocol::Operation operation, const QByteArray & arg0, const QByteArray & arg1, const QByteArray & arg2 ) Constructs a network operation object. operation is the type of the operation, and arg0, arg1 and arg2 are the first three raw data arguments of the operation. The state is initialized to QNetworkProtocol::StWaiting. See also QNetworkProtocol::Operation and QNetworkProtocol::State. QNetworkOperation::~QNetworkOperation () Destructor. QString QNetworkOperation::arg ( int num ) const Returns the operation's num-th argument. If this argument was not already set, an empty string is returned. Example: network/networkprotocol/nntp.cpp. int QNetworkOperation::errorCode () const Returns the error code for the last error that occurred. void QNetworkOperation::free () Sets this object to delete itself when it hasn't been used for one second. Because QNetworkOperation pointers are passed around a lot the QNetworkProtocol generally does not have enough knowledge to delete these at the correct time. If a QNetworkProtocol doesn't need an operation any more it will call this function instead. Note: you should never need to call the method yourself. QNetworkProtocol::Operation QNetworkOperation::operation () const Returns the type of the operation. QString QNetworkOperation::protocolDetail () const Returns a detailed error message for the last error. This must have been set using setProtocolDetail(). QByteArray QNetworkOperation::rawArg ( int num ) const Returns the operation's num-th raw data argument. If this argument was not already set, an empty bytearray is returned. void QNetworkOperation::setArg ( int num, const QString & arg ) Sets the network operation's num-th argument to arg. void QNetworkOperation::setErrorCode ( int ec ) Sets the error code to ec. If the operation failed, the protocol should set an error code to describe the error in more detail. If possible, one of the error codes defined in QNetworkProtocol should be used. See also setProtocolDetail() and QNetworkProtocol::Error. void QNetworkOperation::setProtocolDetail ( const QString & detail ) If the operation failed, the error message can be specified as detail. void QNetworkOperation::setRawArg ( int num, const QByteArray & arg ) Sets the network operation's num-th raw data argument to arg. void QNetworkOperation::setState ( QNetworkProtocol::State state ) Sets the state of the operation object. This should be done by the network protocol during processing; at the end it should be set to QNetworkProtocol::StDone or QNetworkProtocol::StFailed, depending on success or failure. See also QNetworkProtocol::State. QNetworkProtocol::State QNetworkOperation::state () const Returns the state of the operation. You can determine whether an operation is still waiting to be processed, is being processed, has been processed successfully, or failed. SEE ALSO
http://doc.trolltech.com/qnetworkoperation.html http://www.trolltech.com/faq/tech.html COPYRIGHT
Copyright 1992-2001 Trolltech AS, http://www.trolltech.com. See the license file included in the distribution for a complete license statement. AUTHOR
Generated automatically from the source code. BUGS
If you find a bug in Qt, please report it as described in http://doc.trolltech.com/bughowto.html. Good bug reports help us to help you. Thank you. The definitive Qt documentation is provided in HTML format; it is located at $QTDIR/doc/html and can be read using Qt Assistant or with a web browser. This man page is provided as a convenience for those users who prefer man pages, although this format is not officially supported by Trolltech. If you find errors in this manual page, please report them to qt-bugs@trolltech.com. Please include the name of the manual page (qnetworkoperation.3qt) and the Qt version (3.1.1). Trolltech AS 9 December 2002 QNetworkOperation(3qt)
All times are GMT -4. The time now is 05:20 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy