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

  • SEARCH
  • Home
  • 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 8349963
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T08:10:08+00:00 2026-06-09T08:10:08+00:00

What would be the process of making my Python scripts work well with ‘xargs’?

  • 0

What would be the process of making my Python scripts work well with ‘xargs’? For instance, I would like the following command to work through each line of text file, and execute an arbitrary command:

cat servers.txt | ./hardware.py -m 

Essentially would like each line to be passed to the hardware.py script.

  • 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-09T08:10:11+00:00Added an answer on June 9, 2026 at 8:10 am

    To make your commands work with xargs you simply need them to accept arguments. Arguments in Python are in the sys.argv list. In this way you can execute somthing like:

    find . -type f -name '*.txt' -print0 | xargs -0 ./myscript.py
    

    which might be equivalent to

    ./myscript.py ./foo.txt ./biz/foobar.txt ./baz/yougettheidea.txt
    

    To make your commands work with standard input, you can also use the sys module, this time with sys.stdin, which you can treat as a file. This is more like the example you gave:

    ./myscript.py < somefile.txt
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i would like to process an undefinitely long string in C++ by chunks of
I would like to process a frame element in my source xml file using
i would like to process infrared imaging in Matlab. Any kind of processing or
I would like to be able to spawn a linux process that would only
Given a very large string. I would like to process parts of the string
I would like to create a child process in node, and block in a
I would like to make log in process more safely. And to achieve it
I'd like to prevent multiple instances of the same long-running python command-line script from
I'm in the process of making a Python-based personal assistant/question answerer, which, in my
I'm looking for a cross-platform way of making my Python script process a file's

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.