[Tutor] Pass arguments from bash script to embedded python script

Stephen P. Molnar s.molnar at sbcglobal.net
Mon Oct 21 09:45:14 EDT 2019


First of all, let me emphasize that this is not a homework assignment.

I have a large number of data files form a Quantum Chemistry program 
which all have the same format.

I have written a short python script to extract the data required for 
another program.

> #!/usr/bin/env python3
> # -*- coding: utf-8 -*-
> """
>
> Created on Tue Sep 24 07:51:11 2019
>
> """""
> import numpy as np
>
> data = np.genfromtxt(fname, usecols=(1), skip_header=27, 
> skip_footer=1, encoding=None)
>
> print(data)
>
> np.savetxt('fname.dG', data, fmt='%.10g', header='fname1')
> print(data)


and I have a bash script in which I have embedded the python script:

> #!/bin/bash
>
> # Run.dG.list_1
>
> while IFS= read -r d
> do
>     python3 DeltaGTable_V_sw.py
> done <ligand.list
The ligand.list for the bash file have the format:
>
>> fname = ['C-VX3.log', '15-7.log', '14-7.log']
>> fname1 = ['C-VX3', '15-7', '14-7'

where fname and fname1 are three typical data files.

my problem is how do I pass the argument's in the two files from the 
bash script to the python script? It has been suggested to me that the 
solution is an implementation of the sys/.argv function but it seems 
that every reference that I can find goes the other way from python to bash.

So my question is what question should I be goggling? I am not looking 
for someone to write the script for me, but pointers in the correct 
direction.

Thanks in advance.

-- 
Stephen P. Molnar, Ph.D.
www.molecular-modeling.net
614.312.7528 (c)
Skype:  smolnar1



More information about the Tutor mailing list