I want to put the above in a master shell and i want to put the arguments in another file.
I would like my shell to read the arguments from the file IN ORDER and then execute the ./shscript. It is important that the arguments are read in order.
Can someone please tell me how this is done? thanks in advance
I have another question. The same master all the environment variables in a file and then read the file from my shell. How do i go about calling the different variables from the one file. Thanks in advance guys
The following is the sample of the environment variables.
Host = servername
Port = 13122
site = sitename
Javahome = /bin/java
platform= pb
filelist=x.guiclient.download
boot=bot.jar
If you hold your parameter file in correct unix Shell format (no spaces either side of the equals sign and variables in quotes) you can set all the variables with.
I am not great with awk / sed so any help would be greatly appreciated.
I have other requirements to read from a file as well(i am trying to get rid of all hardcoded data) and this will help me out greatly with respect to others as well. Thanks
Then i am executing the following script that is setting the env variable as corona suggessted. But i am getting an error that boils down to the missing the hostname. What am i missing. How do i call the variables from the envfile.sh?
---------- ATTACHED CAUSE ----------
java.lang.Exception: XmlServer does not exist in site mxeod
The script executes if i define all the variables inside the script(without the double quotes). But if i move the variables to the envfile.sh and add the double quotes and then call the file using . ./envfile.sh , i am getting an error.
Thank you very much for your time Methyl. it is very much appreciated.
Thanks a mil Methyl. I found the error and fixed it. The envfile.sh was pointing to a different host than it was supposed to. Thanks for your time
---------- Post updated at 06:07 PM ---------- Previous update was at 05:57 PM ----------
Cheers.. I looked it up and it seems really cool. I'm loving the idea of it.
This works perfectly.But if i make a small tweak to the code and include a if condition inside the while loop, only the alternate arguments are being read. For e.g, if i use the following code:
while read x y
do
./shscript $x $y
if [$y -gt 0 ] ; then
echo The execution was successful
else
echo Execution failed
fi
done < parameters.txt
The arguments that are passed to the shell are as follows
I tried inserting a newline character in the file paramers.txt as below and the program works perfectly. I dont use any breaks in my if.. else command.. I dont want to have to insert a new line in the parameters.txt file. I cant see where the logic is going wrong. :wall:
while read x y z
do
if [ "$z" == "GOD" ] ; then
./shell.sh $x $y
a= parse $y
echo bla bla
if [ $a -gt 0 ] ; then
echo "`read -p "user i/p"`"
else
echo Executing the value............
fi
fi
if [ "$z" == "DEVIL" ] ; then
./ggmu.sh
fi
done<parameters.txt
If i remove the bolded out code above, the script reads the arguments properly!! Why is that if condition screwing up the reading of the parameters.txt file?
It's not the "if" condition, its the "read -p" (which was not mentioned in your previous post). It's in backticks so it still functions within the "echo" line.
There is only one STDIN channel and that "read -p" is eating data from you main read loop. Every alternate record. QED.
Ps. Please take care to post the script and data which matches the symptoms.