As mentioned in the title.
I wrote a script that has pretty long execution time. Some user just close the window half way and in the end cause some file corrupted. Is there any way to prevent the user closing the window? (Like turn the 'x' button of the window title bar grey color?)

Recommended Answers

All 8 Replies

echo "please do not close this window until promted, this may take awhile"

sorry, I was trying to be funny. I am not sure how to do waht you wnat.

there is no real way to stop a user from closing a window using a shell script.

but if your worring about your shell script being half way through something when they close the window.

use

nohup

this makes the process not honour hang up signals

NOTE: you will no long output stuff to the tty, so if you want user imput its prolly best to do as follows, run a process asking for the imput without nohup then run another process accepting the input from the command line with nohup.


I havent checked this but you may also be able to run a function as nohup, I don't know.

thanks for your reply!
but how about if the window is launched using 'cmdtool' command from the script itself? can closing this window be prevented? like disable the 'x' button?

Im not to certain, would depend on your terminal. there might be a way of stopping ppl closing the window in certain terminals.

Hi I know this post has not been updated for awhile, but I am facing the same exact problem like the original poster! Anyone knows of any update to this question?

Hi I know this post has not been updated for awhile, but I am facing the same exact problem like the original poster! Anyone knows of any update to this question?

I would still suggest using nohup atleast if the user closes the terminal you will still be processing.

You can use nohup as follows so your users can see the output of your script.

nohup ./test.sh | cat

If you don't want the user to notice the script running:

nohup script.sh <parameters>  2>&1 > ./logfile &

As long as your script does not ask for user input this will work. Otherwise you will have to resort to nohup and an expect script or nohup and a here document.

I had the same issue, but what i did is i just put time and refresh it every minute or so.
this way the user knows something is happening

commented: Your first and only post is bumping a topic that's three years old?? Come onnnnn.... +0
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.