Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9039833
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T09:49:41+00:00 2026-06-16T09:49:41+00:00

I have an equivalent shell command(shown below) which I am trying to run as-is

  • 0

I have an equivalent shell command(shown below) which I am trying to run “as-is” from a python script using call command on a linux box and running into compilation error,is there a better way other than call to runt this command?where am I going wrong?

from subprocess import call

def main ():

#ssh -p 29418 company.com gerrit query --commit-message --files --current-patch-set status:open project:platform/vendor/company-proprietary/wlan branch:master |grep refs| awk -F ' ' {'print $2'} |tee refspecs.txt
    call (["ssh -p 29418 company.com gerrit query", "--commit-message", "--files", "--current-patch-set", "status:open project:platform/vendor/company-proprietary/wlan branch:master","|grep refs| awk -F ' ' {'print $2'} |tee refspecs.txt")]

if __name__ == '__main__':
    main()
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T09:49:43+00:00Added an answer on June 16, 2026 at 9:49 am
    from subprocess import check_call
    
    with open("refspecs.txt", "wb") as file:
        check_call("ssh -p 29418 company.com "
            "gerrit query --commit-message --files --current-patch-set "
            "status:open project:platform/vendor/company-proprietary/wlan branch:master |"
            "grep refs |"
            "awk -F ' ' '{print $2}'",
                   shell=True,   # need shell due to the pipes
                   stdout=file)  # redirect to a file
    

    I’ve removed tee to suppress stdout.

    Note: either part or even the whole command can be implemented in Python.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does PowerShell have an equivalent to this command construct from sh (and derivatives): $
Using IPython .10-2, I can do the following from a python command line program:
I am trying to write a C shell equivalent script for the bash script
I have a python script that reads from a config file. The config file
I have a Bash shell script in which I would like to pause execution
I have an old shell script which needs to be moved to bash. This
I have a shell script which gets executed. In the script I have: if
I am unfamiliar with Oracle and i need to have equivalent of my script
Am I correct in thinking that that Python doesn't have a direct equivalent for
I have a Ruby script that needs to run about one time a second.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.