GURU SINGH
GURU SINGH

Reputation: 149

Reading commands from text file and passing it into Script in Shell

I have a file.txt whose output is

declare -a Pool=("Minland" "Tucson" "Vancouver")
declare -a Library=("lib1" "lib2" "lib3")
declare -a Name=("Guru" "Albert" "Jeff")
declare -a Email=("[email protected],[email protected]" "[email protected]" "[email protected]")
declare -a Subject=("   Finland Media Rotation" "       Tucson Media Rotation" "        Vancouver Media Rotation")

I want to use these outputs as the command to my other file. Below is my effort.

cat Hello.txt | xargs -d $'\n' sh -c sh Media.sh

It doesn't give any output.

then alternate I have tried is appending like below which work but I know it's not the correct way.

cat file.txt Media.sh > out.sh
chmod +x out.sh
sh out.sh

So, please help me with the best option.

Upvotes: 0

Views: 31

Answers (1)

Pierre François
Pierre François

Reputation: 6063

You can source the content of your file.txt file into the script Media.sh with the next instruction as first instruction of your Media.sh file:

. file.txt

Upvotes: 1

Related Questions