-2

FlushCacheonDP.xml:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Body>
    <m:request xmlns:m="http://www.datapower.com/schemas/management" domain="XXXXX">
        <m:do-action>
            <FlushDocumentCache>
                <XMLManager class="XMLManager">default</XMLManager>
            </FlushDocumentCache>
            <FlushStylesheetCache>
                <XMLManager class="XMLManager">default</XMLManager>
            </FlushStylesheetCache>
        </m:do-action>
    </m:request>
</SOAP-ENV:Body>

I am using it in a curl call inside a python script, my problem is I want to call the curl with the above xml but the domain="XXXXX" has to pick differents strings like from an array.

here is how I am calling it :

from sys import argv
import subprocess
# run python cache2.py hosts.txt Test
with open(argv[1]) as f:
addresses = {i.split(" : ")[0] : i.split(" : ")[1] for i in f}
print(addresses[argv[2]])


command = "curl -k --data-binary @FlushCacheonDP.xml -u username@password   https://" +addresses[argv[2]].strip()+ ":5550/service/mgmt/current > Response2\generated_Resp.xml"
print(command)
p = subprocess.Popen(command,shell=True,  stdout=subprocess.PIPE).communicate()[0]

arrayDomain = ['EOT','ITD_TEST',......,'NSOPR']

I could call the same curl script many times, but it will be a redandont Thanks, your help is appreciated.

5
  • What is your question? Commented Oct 22, 2015 at 17:48
  • and what is the result of your code executing? What is the typical usage of the command line, with sample input? Commented Oct 22, 2015 at 17:49
  • The input is that xml file, when sent to the datapower server, this one reply by another xml file, everything is working fine, my question is there any way to inject domain from the arrayDomail to the FlushCacheonDP.xml before it will be sent ? Commented Oct 22, 2015 at 18:14
  • So you are trying to change the domain attribute of your request element? You may wish to check out stackoverflow.com/questions/1591579/… Commented Oct 22, 2015 at 18:17
  • I want to read the xml file, change only the XXXX write it back to system, then call curl : my_file = open(filename, "r") lines_of_file = my_file.readlines() how to do string manipulation here ??? my_file.writelines(lines_of_file) Commented Oct 22, 2015 at 19:05

1 Answer 1

0

I am all set I used minidom: .attributes["domain"].value = domain Thanks.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.