Can Sikuli run a curl command on the command line?

Asked by arminius

I've run sikuli without the IDE many times, very familiar with doing that from the command line.

Never actually exported a command to the command line though.

example of the curl command.

'curl -X GET "https://doc.tech.net/latest/characters/ME/assets/?datasource=server&page=1" -H "accept: application/json" -H "authorization: Bearer vyJ4jkdciOiZ"'

^^^Been so long I can't remember how to get it into it's own code window.

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

for most flexibility, you should use Pythons subProcess.Popen()

Revision history for this message
arminius (arminius75) said :
#2

I can't use that till I get home.

Is this a likely example?

    import os

    p = os.popen('curl -X GET "https://doc.tech.net/latest/characters/ME/assets/?datasource=server&page=1" -H "accept: application/json" -H "authorization: Bearer vyJ4jkdciOiZ"')
    print(p.read())

Revision history for this message
arminius (arminius75) said :
#3

Oh, should add that the command returns a JSON, I'm either hoping to save it as an object so I can edit it's data, or I just want to save it in a .JSON file.
Whichever is simpler.

Revision history for this message
arminius (arminius75) said :
#4

input

    import os

    first_part = r'curl -X GET "https://doc.tech.net/latest/characters/ME/assets/?datasource=server&page=1" -H "accept: application/json" -H "authorization: Bearer vyJ4jkdciOiZ"'

    print(first_part)

    p = os.popen(first_part)
    print(p.read())

output at the command line
    'curl' is not recognized as an internal or external command,
    operable program or batch file.
    'page' is not recognized as an internal or external command,
    operable program or batch file.

The sikuli output displays "first_part" correctly, but does not display (p.read())

Revision history for this message
RaiMan (raimund-hocke) said :
#5

as mentioned: use subProcess.Popen:
https://www.jython.org/docs/library/subprocess.html#subprocess-subprocess-management

... but any findings do not have to do anything with SikuliX, it is just Python(Jython)

Can you help with this problem?

Provide an answer of your own, or ask arminius for more information if necessary.

To post a message you must log in.