Reading arguments for a shell script from file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Reading arguments for a shell script from file
# 8  
Old 01-11-2012
Quote:
Originally Posted by Corona688
I don't understand the problem. Variables you set in the external file the way methyl suggests can indeed be used in your program.
I am sorry. May be i am not making myself clear here.

I have the following in a file called envfile.sh :
Code:
Host="servername"
Port="13122"
site="sitename"
Javahome="/bin/java"
platform="pb"
filelist="x.guiclient.download"
boot="bot.jar"

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?

Code:
 #!/bin/sh
. ./envfile.sh
java -cp $boot -Djava.security.policy=$policy-codebase=http://$Host:$Port/$Filelist   /Sitename:$Site /Platform_name:$platform

# 9  
Old 01-11-2012
Leading question:
What is in the variable $policy ?
# 10  
Old 01-11-2012
Quote:
Originally Posted by methyl
Leading question:
What is in the variable $policy ?
Apologies methyl.

The envfile.sh does contain the variable policy

Host="servername"
Port="13122"
site="sitename"
Javahome="/bin/java"
platform="pb"
policy="jv.policy"
filelist="x.guiclient.download"
boot="bot.jar"
# 11  
Old 01-11-2012
Try sticking an echo in front of the java line just to see what the expanded line looks like?
# 12  
Old 01-11-2012
Quote:
site="sitename"
Should be
Code:
Site="sitename"

This User Gave Thanks to methyl For This Post:
# 13  
Old 01-11-2012
Quote:
Originally Posted by methyl
Try sticking an echo in front of the java line just to see what the expanded line looks like?
This is the error that i get :
Code:
---------- 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.
# 14  
Old 01-11-2012
There is no difference between having them in a file and having them in your file, ergo there is a typo.

Methyl identified it above for you.
This User Gave Thanks to Corona688 For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Passing Arguments to shell script from file is not working as expected.

Hi All, I have below simple shell script in cloudera quick start vm cenos 6 which copy file from source to destination. # file_copy.sh source_dir = ${source_dir} target = ${target_dir} cp source_dir target and my parameter file is like below #parameter_file.txt source_dir =... (4 Replies)
Discussion started by: Narasimhasss
4 Replies

2. UNIX for Beginners Questions & Answers

Shell script file check throws [: too many arguments

While I am trying to check the filename/s in IF statement of a shell script (RedHat Linux 6) I am getting below error: File check: filename_time2=`date --date='yesterday' +%Y-%m-%d` cd /location/of/the/files/to/copy if then cp server.log-$filename_time2* ../archive/new... (5 Replies)
Discussion started by: Dip
5 Replies

3. Shell Programming and Scripting

php file unable to run shell script with arguments

echo $result=exec("./permit.sh".$_FILES); pls suggest some other method to run shell script in php .:wall::mad: (0 Replies)
Discussion started by: upvan111
0 Replies

4. Shell Programming and Scripting

Error while reading from a file in shell script

Hi All, I'm writing a script to read a file line by line and then perform awk function on it. I am getting an error . My file has one name in it "James". I'm expecting my o/p to be youareJamesbond James ./users.sh: line 7: =: command not found #script to read file line by line #adding... (5 Replies)
Discussion started by: Irishboy24
5 Replies

5. Shell Programming and Scripting

send arguments to a .exe file from a shell script

Folks , can anyone post a sample showing a way to parse a variable containing a string to a .exe file . Thanks Venu (2 Replies)
Discussion started by: venu
2 Replies

6. Shell Programming and Scripting

How to pass arguments to SQL file passed in shell script?

Hi, I am using SYBASE database. in my script i am connecting to DB via using isql. isql -U${S_USER} -S${S_SERV} -D${S_DB} -P${S_PWD} -b0 -w3000 -h0 -s"|" -i${MYDIR}/ABC.sql -oXYZ.txt << FINSQL i am taking a ABC.sql file to use the queries written in it and storing the output in... (3 Replies)
Discussion started by: dazdseg
3 Replies

7. Shell Programming and Scripting

file reading through shell script

For reading a file through shell script I am using yhe code : while read line do echo $line done<data.txt It reads all the line of that file data.txt. Content of data.txt looks like: code=y sql=y total no of sql files=4 a.sql b.sql c.sql d.sql cpp=n c=y total no of c files=1 (4 Replies)
Discussion started by: Dip
4 Replies

8. Solaris

Passing arguments to a shell script from file while scheduling in cron

Hi, I have a shell script Scp_1.sh for which I have to pass 2 arguments to run. I have another script Scp_2.sh which in turns calls script Scp_1.sh inside. How do I make Scp_1.sh script to read arguments automatically from a file, while running Scp_2.sh? -- Weblogic Support (4 Replies)
Discussion started by: weblogicsupport
4 Replies

9. Shell Programming and Scripting

Reading file names from a file and executing the relative file from shell script

Hi How can i dynamically read files names from a list file and execute them from a single shell script. Please help its urgent Thanks in Advance (4 Replies)
Discussion started by: anushilrai
4 Replies

10. UNIX for Dummies Questions & Answers

Reading runtime arguments from a file

Hi All, I am running a script which wud take a long time to complete execution ... In between, it asks for yes/no sort of confirmation from user for doing some acivities .... Now that I dont want to wait till the script executes upto this point where it needs user confirmation, is there any way... (4 Replies)
Discussion started by: Sabari Nath S
4 Replies
Login or Register to Ask a Question