0

I'm trying to form a cURL using string concatenation in Python. I have a custom command and I'm not sure if I can use requests for this.

cmd='curl -u admin:'+password+' -F file=@'+package+' -F name='+package+' -F force=false -F install=true http://'+ip+':5101/crx/packmgr/service.jsp'
    
print(cmd)

Error:

curl -u admin:******** -F file=@abc_xyz.zip
 -F name=abc_xyz.zip
 -F force=false -F install=true http://8.8.8.8:5101/crx/packmgr/service.jsp
curl: no URL specified!
curl: try 'curl --help' or 'curl --manual' for more information
sh: line 1: -F: command not found
sh: line 2: -F: command not found
32512

And yes I have tried escape '' as well. Didn't work.

Any help would be greatly appreciated. TIA

3
  • Do have line endings in your password variable? Try password = password.strip() before construncting the command. Or, more likely in package variable? Commented Jun 10, 2021 at 15:23
  • Nope password = password.strip() did not work. Commented Jun 10, 2021 at 15:27
  • Now try with package = package.strip() Commented Jun 10, 2021 at 15:27

1 Answer 1

1

Looks like your constructed command has line endings after the package variable, try stripping it from extra symbols:

package = package.strip()
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.