python script

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

python script

Roshan
Hello Erman,

I use 1 curl command to generate a token to autostart a pipipeline for Striim.

 curl -X POST -d'username=admin&password=striim$$2022' http://localhost:9080/security/authenticate
{"token":"01ecd1d9-99b0-c511-b106-005056819aa2"}[striim@RB-BD-STRIM-NEW ~]$

Is there any python code to call the curl command and save this token in a variable?

Thanks,

Roshan
Reply | Threaded
Open this post in threaded view
|

Re: python script

ErmanArslansOracleBlog
Administrator
So you use curl and make a HTTP Post to a url with the token attached..
I don't have that code written. But it can be written easily..
You can do it Roshan, just declare a variable and build and run the OS command (curl) from that script by using the value of that variable.

to run the OS command from Python , you can use the subprocess..

For ex:

import subprocess
proc = subprocess.Popen(['echo', name],
                            stdin = subprocess.PIPE,
                            stdout = subprocess.PIPE,
                            stderr = subprocess.PIPE
                        )

(out, err) = proc.communicate()
print out

You can also use os.system() for this task..