943,987 Members | Top Members by Rank

Ad:
Aug 7th, 2005
0

how to prevent user close window during script execution?

Expand Post »
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?)
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
rinque is offline Offline
3 posts
since Aug 2005
Aug 8th, 2005
0

Re: how to prevent user close window during script execution?

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.
Reputation Points: 10
Solved Threads: 17
Posting Whiz in Training
shanenin is offline Offline
217 posts
since May 2005
Aug 8th, 2005
0

Re: how to prevent user close window during script execution?

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

Shell Scripting Syntax (Toggle Plain Text)
  1. 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.
Reputation Points: 21
Solved Threads: 10
Junior Poster
Paul.Esson is offline Offline
181 posts
since Feb 2005
Aug 9th, 2005
0

Re: how to prevent user close window during script execution?

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?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
rinque is offline Offline
3 posts
since Aug 2005
Aug 18th, 2005
0

Re: how to prevent user close window during script execution?

Im not to certain, would depend on your terminal. there might be a way of stopping ppl closing the window in certain terminals.
Reputation Points: 21
Solved Threads: 10
Junior Poster
Paul.Esson is offline Offline
181 posts
since Feb 2005
Oct 25th, 2006
0

Re: how to prevent user close window during script execution?

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?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
hungtat is offline Offline
1 posts
since Oct 2006
Oct 25th, 2006
0

Re: how to prevent user close window during script execution?

Click to Expand / Collapse  Quote originally posted by hungtat ...
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.

Shell Scripting Syntax (Toggle Plain Text)
  1. nohup ./test.sh | cat
Last edited by Paul.Esson; Oct 25th, 2006 at 9:34 pm.
Reputation Points: 21
Solved Threads: 10
Junior Poster
Paul.Esson is offline Offline
181 posts
since Feb 2005
Oct 26th, 2006
0

Re: how to prevent user close window during script execution?

If you don't want the user to notice the script running:
Shell Scripting Syntax (Toggle Plain Text)
  1. 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.
Last edited by jim mcnamara; Oct 26th, 2006 at 6:27 pm.
Reputation Points: 62
Solved Threads: 10
Junior Poster
jim mcnamara is offline Offline
179 posts
since May 2004
Aug 25th, 2009
-1

Re: how to prevent user close window during script execution?

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
rashshell is offline Offline
1 posts
since Aug 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Shell Scripting Forum Timeline: Windows batch script
Next Thread in Shell Scripting Forum Timeline: How not to show messages?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC