shell script help needed.
Hi,
I have been trying to write a script which allows me to edit the default input value.
Let me explain it here what exactly I am trying to do:
My script execution will be like this...
Enter the location to install :/home/kssm_
here with in my script I want to give the user of the script with a default value /home/kssm which should be editable. The user should be able to edit the default input value.
I am tired experimenting with 'stty icanon'.
I have seen such type of things done in many installation programs.
I would like to know how it could be done.
Thanks,
Mitra.
# 1
If user input is to happen during script execution you could take a look at 'read' in the man page for 'ksh'...if you're using the Solaris default shell.
When input is read into a variable you can manipulate the location name in your script .
Alternatively you can take the input as an argument to the script upon execution - which will be available in the appropriate variable, $1 for first argument.
-R
# 3
I see that now.
However, using 'read' would be a quick fix - user inputs nothing = keep default, user inputs alternative = new location in script.
However, actually giving the user a line editor through the script is a different thing altogether - and now I'm curious too.
-R
# 5
... I am curious as to why you want to do this.. what would the practical use be...... also, you said that you have seen this in "installation programs"... are those in command line or GUI? I can see how this could be done in Java or XML, but Korn?
# 6
Take a look at the GNU readline(3) subroutine. It does what you're looking for. You could probably write a small C-program (statically linked) that could do the job for you. I'm sure there's a Perl version available, if you're into Perl.HTH,Roger S.