0

hi

probably a noob qustion but this is my first attempt at shell scripting.

im trying to open a file in a new window that the user types the name of during the run time of the script. i have tryed several different ways of doing this including.

read >> sh
read >> exec
ect...

any help would be appriciated.

thanks

Sam

2
Contributors
3
Replies
4
Views
11 Years
Discussion Span
Last Post by masijade
0

Okay try the following sample of code. It will ask the user to enter
the file name, then open an xterm with a vi of the file then continue
with the script without waiting for the user to close the file again. If you
wish the script to wait until the user closes the file remove the "&" from
the xterm line.

echo "Enter filename:"
read file bogus
xterm -e vi $file &
0

thanks for that, works perfecly. i also swaped the vi command for sh in another part of the script to execute the file instead, should this work?

cheers sam

0

Shouldn't be a problem. Just remember that the xterm will close as soon
as the script finishes without leaving any delay to read messages so you
may wish to add

>somefile 2>&1

directly before the & at the end of the command.
This will capture the output (with errors) into "somefile".

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.