Register
It is currently Fri Oct 31, 2014 5:26 am

control character in the script?


All times are UTC - 6 hours


Post new topic Reply to topic  [ 5 posts ] 
Author Message
 PostPosted: Tue Mar 20, 2012 9:13 pm   

Joined: Tue Mar 20, 2012 9:04 pm
Posts: 2
how can i inject a control character in the script (e.g ctrl - C)? my objective is to terminate an active console session when someone enters a command that is not allowed to use.


Top
 Profile  
 PostPosted: Wed Mar 21, 2012 3:40 am   
Moderator
User avatar

Joined: Thu Oct 11, 2007 7:12 am
Posts: 229
Location: London - UK
Maybe try sending a signal instead of attempting to use crtl-c, there is a section on it in the bash man page.


Top
 Profile  
 PostPosted: Wed Mar 21, 2012 9:23 am   
Moderator
User avatar

Joined: Wed May 03, 2006 2:05 pm
Posts: 242
Is this within the context of a script? If not, how are you planning to monitor what commands are being entered?
Is there a reason you don't want to simply control what the user has access to with file permissions instead?


Top
 Profile YIM  
 PostPosted: Thu Mar 22, 2012 7:26 pm   

Joined: Tue Mar 20, 2012 9:04 pm
Posts: 2
@ jeo
i believe its within the script.

@darthway
i'll try that. by the way its a remote user that i want to terminate his/her console session.


Top
 Profile  
 PostPosted: Fri Mar 23, 2012 9:41 am   
Moderator
User avatar

Joined: Wed May 03, 2006 2:05 pm
Posts: 242
Ok! If you run something like this from inside a script, it should kill the session, but it won't save history or anything useful like that. Do you want to block them from returning, or just kick them out?

Code:
kill -9 $(ps -p $$ -o ppid=)


I'm not sure if there's a "proper" way to exit the shell from inside a script...


Top
 Profile YIM  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot] and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP