Reputation: 3
Suppose I have two functions function_arguments1 and function_agruments2 which are accepting parameters. I want to call the function name:- function_argument1, from python script. How should I call the function_arguments1 from Python passing parameters from python script.
#!/bin/bash
#Script to pass and access arguments
function_arguments1(){
echo $1
echo $2
echo $3
echo $4
echo $5
}
function_argument2(){
echo $1
echo $2
}
#Calling function_arguments2
function_arguments2 "Please""Help"
Upvotes: 0
Views: 164
Reputation: 73
import subprocess
subprocess.Popen(['bash', '-c', '. bash_script.sh; function_argument2 Please Help'])
To pass input arguments from a list:
inputs = ['Hello', 'How', 'What']
for input_ in inputs:
subprocess.Popen(['bash', '-c', f'. bash_script.sh; function_argument2 {input_}'])
Upvotes: 1