Hi,
I am new to shell scripting (sh)
I need a script which will call a utility & once u call it.It will ask for inputs on the screen.These inputs it needs to get or read from a txt file.
for e.g
#! /bin/sh
while read line
do
echo $line
done
txt file will have
test
01/01/2008
pls can u help me on how to call any utility or program from script and read file for inputs.
Thks in adv.
Suppose that you have a script like this:
#!/bin/bash
##blah
##blah
/path/to/utility
#more blah
In this case, your utility will ask for input from the user and your script will not proceed till your utility completes - the 'more blah' section will be run only after the utility exits. If you want to provide the input to utility, then do this:
/path/to/utility <<EOF
input 1
input 2
EOF
Sorry, you are using a text file, I missed that. Do this:
/path/to/utility < /path/to/txt_file
Thks.I will try it & let you know.
/path/to/utility < /path/to/txt_file
input 1 ----is this step required?
input 2----is this step required?
EOF----is this step required?
I will write something like this. script based on ur advise as below.
xyz.sh
#! /bin/sh
/path/to/utility < /path/to/xyz.txt
xyz.txt will have
test (filename to be passed as a parameter)
01/01/2008
Thks ,It worked.Now a some modification to script is required.Pls can you help.
Earlier i was reading from the txt file and giving inputs to the utility.
Now i need to create i.e write .txt file & then use this txt file to give the inputs to the directory.
Basically the txt file will be a calender creation. how to i do it.if
xyz.sh filename,frm_date,to_date,interval
where filename = .txt filename
frm_date=01/01/2008
to_date=02/15/2008
interval=2
so it should create a two month calender if interval is 2 then alternate day
if interval is blank it should be a daily calender i.e all days.
and the script should have date check of 30/31 day & leap year check.
Thks