Hello,
I would like done the following functionality.
At launching time
1) If argument is added to the script-name, argument is used as variable via $1 positional parameter.
2) If no argument is added to the script-name, argument is prompted and read via read v1? command.
It does not work because if option 1) is used first $1 positional parameter is always present, so case 2 appears only if "" is passed as argument
shell ksh
f1=$1
echo "v1: $1"
if [ -z "$f1" ]
then
read f1?"Enter filename: "
echo "file: $f1"
read f2?"output filename : "
else
f2=$2
fi
unix > . rvr*h aaa
v1: aaa
unix > . rvr*h
v1: aaa
unix > echo $1
aaa
unix >
unix > . rvr*h ""
v1:
Enter filename: bb
file: bb
output filename :
unix > echo $1
Do you have any idea to solve it?
Thanks in advance,
I would like done the following functionality.
At launching time
1) If argument is added to the script-name, argument is used as variable via $1 positional parameter.
2) If no argument is added to the script-name, argument is prompted and read via read v1? command.
It does not work because if option 1) is used first $1 positional parameter is always present, so case 2 appears only if "" is passed as argument
shell ksh
f1=$1
echo "v1: $1"
if [ -z "$f1" ]
then
read f1?"Enter filename: "
echo "file: $f1"
read f2?"output filename : "
else
f2=$2
fi
unix > . rvr*h aaa
v1: aaa
unix > . rvr*h
v1: aaa
unix > echo $1
aaa
unix >
unix > . rvr*h ""
v1:
Enter filename: bb
file: bb
output filename :
unix > echo $1
Do you have any idea to solve it?
Thanks in advance,