User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Shell Scripting section within the Software Development category of DaniWeb, a massive community of 401,693 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,700 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Views: 6990 | Replies: 7
Reply
Join Date: Aug 2005
Posts: 3
Reputation: rinque is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
rinque rinque is offline Offline
Newbie Poster

how to prevent user close window during script execution?

  #1  
Aug 7th, 2005
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?)
AddThis Social Bookmark Button
Reply With Quote  
Join Date: May 2005
Posts: 215
Reputation: shanenin is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
shanenin shanenin is offline Offline
Posting Whiz in Training

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

  #2  
Aug 8th, 2005
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.
Reply With Quote  
Join Date: Feb 2005
Location: Ballarat, Australia
Posts: 164
Reputation: Paul.Esson is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 6
Paul.Esson's Avatar
Paul.Esson Paul.Esson is offline Offline
Junior Poster

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

  #3  
Aug 8th, 2005
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



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.
Reply With Quote  
Join Date: Aug 2005
Posts: 3
Reputation: rinque is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
rinque rinque is offline Offline
Newbie Poster

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

  #4  
Aug 9th, 2005
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?
Reply With Quote  
Join Date: Feb 2005
Location: Ballarat, Australia
Posts: 164
Reputation: Paul.Esson is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 6
Paul.Esson's Avatar
Paul.Esson Paul.Esson is offline Offline
Junior Poster

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

  #5  
Aug 18th, 2005
Im not to certain, would depend on your terminal. there might be a way of stopping ppl closing the window in certain terminals.
Reply With Quote  
Join Date: Oct 2006
Posts: 1
Reputation: hungtat is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
hungtat hungtat is offline Offline
Newbie Poster

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

  #6  
Oct 25th, 2006
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?
Reply With Quote  
Join Date: Feb 2005
Location: Ballarat, Australia
Posts: 164
Reputation: Paul.Esson is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 6
Paul.Esson's Avatar
Paul.Esson Paul.Esson is offline Offline
Junior Poster

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

  #7  
Oct 25th, 2006
Originally Posted by hungtat View Post
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
Last edited by Paul.Esson : Oct 25th, 2006 at 8:34 pm.
Reply With Quote  
Join Date: May 2004
Posts: 177
Reputation: jim mcnamara is on a distinguished road 
Rep Power: 5
Solved Threads: 9
jim mcnamara jim mcnamara is offline Offline
Junior Poster

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

  #8  
Oct 26th, 2006
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.
Last edited by jim mcnamara : Oct 26th, 2006 at 5:27 pm.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Shell Scripting Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Shell Scripting Forum

All times are GMT -4. The time now is 8:04 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC