Arguments to scripts


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Arguments to scripts
# 1  
Old 06-27-2014
Arguments to scripts

Hi All,

i have a requirement, that script should take inputs/arguments from a file.

1. There is already a script which will ask for input for execution of next step, say: date, reason. name etc....
2. I dont have read or write access to this script just execute permissions.


I tried using basic while loop but it is not helping me. below is the code.

Code:
 echo " Starting WAM "
while read a
do 
/usr/local/wam/start.sh 
echo " $a "   # placed for testing purpose
done < input.txt

please help.

Thanks in advance !!
# 2  
Old 06-27-2014
Hi,
from above, my understanding is that u need to pass arguments to "/usr/local/wam/start.sh" script. your code looks fine, u would change like this

Code:
echo " Starting WAM "
while read a
do 
  /usr/local/wam/start.sh $a
  echo " $a "   # placed for testing purpose
done < input.txt

But if script needs more input then you need to parse values in $a variable and pass them to it.
can you show how the values are in input.txt file??

Thanks,

Last edited by Franklin52; 06-27-2014 at 09:06 AM.. Reason: Please use code tags
This User Gave Thanks to newbieabc For This Post:
# 3  
Old 06-27-2014
The for replying newbieabc..
My input.txt will contain
1. Reason for running script... generally a line
2. Current date.
3. Numerical value say 2
Script will first take the first input... will update in some log ( am not sure where it gets updated) ..
Same with other inputs also. ..
# 4  
Old 06-27-2014
Quote:
2. I dont have read or write access to this script just execute permissions.
I dont see how you expect to run a script you cant read...
# 5  
Old 06-27-2014
Hi vbe.. that script is maintained by my client. . And we are operation team .. so they gave our group execute permission..
We just need to run the script
# 6  
Old 06-27-2014
If your script is one that is expected to run in interactive mode: Since its will ask to enter things (and then read the input after pressing Enter Key...) I dont see how you will be able to get it to accept values, and we cant help without seeing the script...
You best bet is to use expect utility, search the forum for expect usage
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Calling multiple scripts from another scripts

Dear all, I am working on script which call other shell scripts in a loop but problem is from second script am not able to come out. Here is the snippet:- #!/bin/bash HSFILE=/root/Test/Components.txt LOGFile=/opt/domain/AdminDomain/application/logs... (3 Replies)
Discussion started by: sharsour
3 Replies

2. UNIX Desktop Questions & Answers

scripts taking arguments

I am trying to write a script using commands to print a sequence of numbers. However, I can't get jot to recognize what I give it. Terri$ cat mncmd echo "m=$1" echo "n=$2" $jot $2 Terri$ ./mncmd 1 10 m=1 n=10 ./mncmd: line 3: $2: command not found I've also tried Terri$ cat... (3 Replies)
Discussion started by: justOne21
3 Replies

3. Shell Programming and Scripting

KSH - How to call different scripts from master scripts based on a column in an Oracle table

Dear Members, I have a table REQUESTS in Oracle which has an attribute REQUEST_ACTION. The entries in REQUEST_ACTION are like, ME, MD, ND, NE etc. I would like to create a script which will will call other scripts based on the request action. Can we directly read from the REQUEST_ACTION... (2 Replies)
Discussion started by: Yoodit
2 Replies

4. Shell Programming and Scripting

grep with two arguments to arguments to surch for

Hello, is it possible to give grep two documents to surche for? like grep "test" /home/one.txt AND /home/two.txt ? thanks (1 Reply)
Discussion started by: Cybertron
1 Replies

5. Shell Programming and Scripting

Changing the Bash Scripts to Bourne Scripts:URGENT

Hi, I have to write a program to compute the checksums of files ./script.sh I wrote the program using bash and it took me forever since I am a beginner but it works very well. I'm getting so close to the deadline and I realised today that actually I have to use normal Bourne shell... (3 Replies)
Discussion started by: pgarg1989
3 Replies

6. Shell Programming and Scripting

Running scripts within scripts from cron

Hi all, I have set up a cron job which calls another shell script shell script which in turn calls a Java process. The cron tab looks so. 0,30 7-18 * * 1-5 /u01/home/weblogic/brp/bin/checkstatus.sh >> /u01/home/weblogic/logs/checkstatus.log The checkstatus.sh scripts looks like this. ... (4 Replies)
Discussion started by: sirbrian
4 Replies

7. Shell Programming and Scripting

Help with Script using rsh and scripts within scripts

Hi, I've written a script that runs on a Database server. It has to shutdown the Application server, do an Oracle Dump and then restart the Application server. Its been a long time since I wrote any shells scripts. Can you tell me if the scripts that I execute within my script will be executed... (3 Replies)
Discussion started by: brockwile1
3 Replies

8. Shell Programming and Scripting

Passing Arguments in Shell Scripts

Hello everybody! First time posting here:) Right, I am trying to pass arguments in my shell scripts using $1, $2 and $3 etc using if else statement........ This is my shell script which is based on serching the google website #!/bin/sh wget -t1 -E -e robots=off - -awGet.log -T 200 -H... (47 Replies)
Discussion started by: kev_1234
47 Replies

9. UNIX for Dummies Questions & Answers

Profile scripts versus rc scripts....

what is the difference between login and profile scripts versus the rc scripts? (1 Reply)
Discussion started by: rookie22
1 Replies

10. Shell Programming and Scripting

Passing and using arguments in Scripts.

I am new to scripting in AIX / UNIX. I have a script that runs 4 other scripts and I want to be able to pass in a agrument that I can check before I run the next script to see if the previous script finished with no errors. Can someone send me an example of this as I'm sure it's pretty easy to... (1 Reply)
Discussion started by: David.Vilmain
1 Replies
Login or Register to Ask a Question