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 1808194
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T06:13:52+00:00 2026-05-17T06:13:52+00:00

I have a python script called mythicalPythonBindings.py. It outputs something like Establishing database connection

  • 0

I have a python script called mythicalPythonBindings.py. It outputs something like

Establishing database connection
chanid = 1952
starttime = 2010-09-29 08:12:00
endtime = 2010-09-29 08:30:00
basename = 1952_20100929081200.mpg
stars = 0.0

I need to read this information into variables of the same name in a bash script. My bash script looks like this

#! /bin/bash

/usr/local/bin/mythicalPythonBindings.py --filename='1952_20100929081200.mpg' --DBHostName='192.168.1.110' --DBName='mythconverg' --DBUserName='mythtv' --DBPassword='mythtv' --output=./ReturnFile.txt --display|
   while read line
     do 
     case "$line" in
         "basename = "* ) 
              echo $line
              basename=`echo "$line" |sed s/'basename = '//g`
              echo $basename
         ;;
     esac
   done
echo $basename
#doing more stuff 

The problem is that when setting variables inside the piped output from mythicalPythonBindings.py, it does not export the variables. The statement “echo $basename”(inside the piped output) works, but the seccond “echo $basename”(outside the piped output) does not work.

How can I set these variables for use in the rest of the script?

edit: I need this variable to be used in other commands without saving the data to a file which must be deleted later.

  • 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-05-17T06:13:52+00:00Added an answer on May 17, 2026 at 6:13 am

    The while loop creates a subshell when something is piped into it. To avoid that you can redirect process substitution into the done:

    pythonfunc () {
        /usr/local/bin/mythicalPythonBindings.py --filename='1952_20100929081200.mpg' --DBHostName='192.168.1.110' --DBName='mythconverg' --DBUserName='mythtv' --DBPassword='mythtv' --output=./ReturnFile.txt --display
    }
    
    while ...
    do
        ...
    done < <(pythonfunc)
    echo $basename
    

    I would use

    read var equals value
    # do some validation
    declare $var=$value
    

    Using declare in this way allows you to avoid using eval.

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

Sidebar

Related Questions

Suppose I have a python script called my_parallel_script.py that involves using multiprocessing to parallelize
I have a python script running on a small server that is called in
Suppose I have a perl (or python) script that does something highly secretive; I'd
Here's the scenario: I have a Python script that is called from a browser
I have a python script called showdate.py which I want to map to I
I have a Python script that is always called from a shell, which can
I have a python script called class.py with one line: class.py: print Hello World
I have a php script that I called in command line like that :
I have python script which downloads N number of images from website. I run
I have a python script that runs a program, which generates few .exe files

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.