+1 vote
in Operating Systems by (88.7k points)

I have created a bash script to run a Python code with input different files. However, when I submit the script, it does not show which input is currently being processed. Is there anyway to display with command is currently under progress?

Here is an example of my script:

time python pu_estimator.py -inpfile file1.csv

time python pu_estimator.py -inpfile file2.csv

time python pu_estimator.py -inpfile file3.csv

time python pu_estimator.py -inpfile file4.csv

1 Answer

+2 votes
by (15.9k points)
selected by
 
Best answer

To display the currently running command in your Bash script, you can use the "set -x" option or explicitly echo each command before executing it. The "set -x" option enables command tracing.

Here is your modified script:

set -x # Enables command tracing

time python pu_estimator.py -inpfile file1.csv

time python pu_estimator.py -inpfile file2.csv

time python pu_estimator.py -inpfile file3.csv

time python pu_estimator.py -inpfile file4.csv

set -x # Disables command tracing

Using echo command:

echo "Running with file1"

time python pu_estimator.py -inpfile file1.csv

echo "Running with file2"

time python pu_estimator.py -inpfile file2.csv

echo "Running with file3"

time python pu_estimator.py -inpfile file3.csv

echo "Running with file4"

time python pu_estimator.py -inpfile file4.csv

Let me know if these changes worked for you. 


...