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

Recommended Answers

All 3 Replies

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 &

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

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".

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.