LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-11-2004, 03:30 PM   #1
jpan
Member
 
Registered: Aug 2004
Distribution: Debian Libranet
Posts: 69

Rep: Reputation: 15
Howto disable user input on the console?


Hi, i'm doing a fork() on my program, while my
child process does a ssh tunneling then parent process
doing vncviwer. when i run my program, my console will
output the result of ssh and then go to the prompt to the
machine that be tunneled. I want to block the user input
so that users can do nothing on my console after i run
my program. What should i do?

thanks a lot, i'm a newbie.

Jimmy
 
Old 08-11-2004, 03:59 PM   #2
infamous41md
Member
 
Registered: Mar 2003
Posts: 804

Rep: Reputation: 30
i'm not sure if i fully understand your question, but try closing STDIN_FILENO and STDOUT_FILENO.
 
Old 08-11-2004, 05:53 PM   #3
jpan
Member
 
Registered: Aug 2004
Distribution: Debian Libranet
Posts: 69

Original Poster
Rep: Reputation: 15
thanks! can you tell me how to close them? by a system call or other functions?

Jimmy
 
Old 08-11-2004, 06:05 PM   #4
jpan
Member
 
Registered: Aug 2004
Distribution: Debian Libranet
Posts: 69

Original Poster
Rep: Reputation: 15
i tried close(STDIN_FILENO);
and close(STDOUT_FILENO);

but i can still type in the console....any other suggestions?
 
Old 08-11-2004, 08:46 PM   #5
infamous41md
Member
 
Registered: Mar 2003
Posts: 804

Rep: Reputation: 30
so u want to not even be able to type? i guess you could mess with the termios settings and disable character echoing. however, the above method, even though you can still type, the input isn't going to be read. i guess that isn't good enough though? check out 'man termios'
 
Old 08-12-2004, 03:12 PM   #6
jpan
Member
 
Registered: Aug 2004
Distribution: Debian Libranet
Posts: 69

Original Poster
Rep: Reputation: 15
but if i do "close(STDIN_FILENO) ;" in my child process, then the following
"execl(...)" in the child process won't work, how to solve the problem?
 
Old 08-12-2004, 03:22 PM   #7
jpan
Member
 
Registered: Aug 2004
Distribution: Debian Libranet
Posts: 69

Original Poster
Rep: Reputation: 15
let me clarify my question: in my child process generated by fork(), i'm going to do
a execl() for executing ssh to login into a remote machine. I was trying to block/disable
the user input after login into the remote machine, say the user can't input at the prompt
of the remote machine. So how can i do that?


Jimmy
 
Old 08-12-2004, 03:53 PM   #8
infamous41md
Member
 
Registered: Mar 2003
Posts: 804

Rep: Reputation: 30
you can try messing with termios like i mentioned above, but other than that i can't think of anything.
 
Old 08-12-2004, 04:59 PM   #9
Cedrik
Senior Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 244Reputation: 244Reputation: 244
Or you can try put ' stty igncr ' in a login script, that will ignore the return or enter key

Last edited by Cedrik; 08-12-2004 at 05:01 PM.
 
Old 08-12-2004, 05:28 PM   #10
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Ubuntu/WSL
Posts: 9,785

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
Perhaps "ssh -n"
 
Old 08-12-2004, 07:10 PM   #11
jpan
Member
 
Registered: Aug 2004
Distribution: Debian Libranet
Posts: 69

Original Poster
Rep: Reputation: 15
ssh -n did work, but after i logged in by execl("...ssh",....), the format of the text on screen was in a mess, like the following:

rem@domrep:~$ VNC server supports protocol version 3.3 (viewer 3.3)
No authentica tion needed
Desktop name "nobody's x11 desktop (uml1:1)"
Connected to VNC server, using protocol version 3.3
VNC server default format:
32 bits per pixel.
Least significant byte first in each pixel.
True colour: max red 255 green 255 blue 2 55, shift red 16 green 8 blue 0
Warning: Cannot convert string "-*-helvetica-bold -r-*-*-16-*-*-*-*-*-*-*" to type FontStruct
Using default colormap which is TrueC olor. Pixel format:
16 bits per pixel.
Least significant byte first in each p ixel.
True colour: max red 31 green 63 blue 31, shift red 11 green 5 blue 0
Usin g shared memory PutImage
Same machine: preferring raw encoding
ShmCleanup called
jimmy@linux:~> jimmy@linux:~> jimmy@linux:~> jimmy@linux:~> jimmy@linux:~> jimmy@linux:~> jimmy@linux:~> jimmy@linux:~> jimmy@linux:~> jimmy@linux:~> jimmy@linux:~> jimmy@linux:~> jimmy@linux:~> jimmy@linux:~> jimmy@linux:~>
jimmy@linux:~> jimmy@linux:~>




is there anything wrong?
 
Old 08-12-2004, 07:55 PM   #12
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Ubuntu/WSL
Posts: 9,785

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
I can't tell, did vnc stopped prematurely ?
 
Old 08-12-2004, 08:04 PM   #13
jpan
Member
 
Registered: Aug 2004
Distribution: Debian Libranet
Posts: 69

Original Poster
Rep: Reputation: 15
i closed vnc manually. is that a problem?
 
Old 08-12-2004, 08:12 PM   #14
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Ubuntu/WSL
Posts: 9,785

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
Well, I can't speak for you.
Are you happy with the solution, or something still bother you ?
 
Old 08-12-2004, 08:55 PM   #15
jpan
Member
 
Registered: Aug 2004
Distribution: Debian Libranet
Posts: 69

Original Poster
Rep: Reputation: 15
i'm still not satisfied with the result, 'coz after i close vnc and the console itself terminate
the ssh connection, the format of the prompt and input became messy as you saw it on
my previous post. Say, when you press ENTER, the next prompt should appear on the next
line, not just a space away following the prior one.


Jimmy
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Disable mouse, keyboard or other input devices / drivers bastl Programming 0 05-15-2005 07:39 AM
Howto write XF86 Input Module? ZX_SA Programming 0 05-11-2005 10:11 AM
How to disable F11 user input? jpan Linux - General 3 09-17-2004 04:28 AM
how do i disable keyboard input? thebover Linux - Newbie 5 08-24-2004 11:13 AM
console input in perl! farhanali Programming 7 06-12-2003 03:27 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:11 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration