473,320 Members | 1,904 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Writing into Keyboard buffer in AIX

Hello All,

I'm really looking for a help in reading/writing the keyboard buffer in AIX (IBM Unix). In DOS, there is some memory addres (I remember it as 0x417) from where the keyboard buffer starts. But I need the same in AIX.

My requirement is this. In AIX, we need to change the password every 60 days or so. And while changing, it wont accept the previous 4 passwords we used. But when you change to a new one, its difficult to remember the current pwd everytime. (You may say to write it some where. But thats clumsy!!).

Suppose my pwd is "welcome". When it expires, I will change it to a new pwd, say passwd1. Then I will change the same 3 more times with some junk pwds and the fourth time, I will give the old pwd itself (ie, "welcome").

In AIX, we can change the password using "passwd", but here the issue is that, it wont accept the password as a parameter and will be waiting for us to enter it through keyboard. Also, please note that I'm a normal user and not the "root".

Thats when I planned to go for mutli-threading where in one thread, I will be running the "passwd" program and when it waits for the pwd, through another thread I will provide the password. There comes the requirement of writing into the keyboard buffer directly...

Any body knows about this, please help me... :(

T&R
Muthursyamburi
Dec 12 '07 #1
3 5201
RRick
463 Expert 256MB
From what I can tell, you want to use the passwd program to change the user's password without any user intervention. That's fine.

Passwd is expecting info on stdin, and one way to fix the problem is to redirect passwd's stdin. From a script,
Expand|Select|Wrap|Line Numbers
  1. ##  Input from a file
  2. passwd < newStuff.txt
  3.  
  4. ## Input from File Descriptor 5 (I think)
  5. passwd <5
  6.  
This can be done programmatically, via fork and exec calls, but I don't have the details.

There are some programs that check to see if stdin is from a terminal, and won't let you redirect a file to it. In that case, you can directly access the input buffer, but this is based on what Unix calls tty. Try "man -k tty" for more details.
Dec 12 '07 #2
From what I can tell, you want to use the passwd program to change the user's password without any user intervention. That's fine.

Passwd is expecting info on stdin, and one way to fix the problem is to redirect passwd's stdin. From a script,
Expand|Select|Wrap|Line Numbers
  1. ##  Input from a file
  2. passwd < newStuff.txt
  3.  
  4. ## Input from File Descriptor 5 (I think)
  5. passwd <5
  6.  
This can be done programmatically, via fork and exec calls, but I don't have the details.

There are some programs that check to see if stdin is from a terminal, and won't let you redirect a file to it. In that case, you can directly access the input buffer, but this is based on what Unix calls tty. Try "man -k tty" for more details.
Hi,

Thanks for understanding my requirement exactly and giving me a prompt reply. However, I tried both the ways but in vain... :(.

1) I tried to redirect a file containing pwds to that it didn't work.
2) I wrote one c program which, using fork() & execvp(), will call a shell in another thread in which I will be running the "passwd". Then through the c program I tried sending the pwds thru message pipes and in the shell program I redirected it from the pipe (I used the file descriptor 3) to the passwd. That also didn't worked out...

After a lot of search in the web, I could get one function called "g32_send_keys()" (see this: g32_send_keys ) but the associated header files (g32_api.h & g32_keys.h) is not there in my system and thus that also didn't work out... :((

T&R
Muthursyamburi
Dec 13 '07 #3
RRick
463 Expert 256MB
I took a look at the man info for passwd on my Linux box. Since you are not root, you will be able only change your account's password. You can't change anyone else's passwd.

On linux, there is a --stdin option that allows information to be received from, you guessed it, stdin. Unfortunately, you must be root to use this. From everything I've seen, this looks like the best solution.

Finally, I'm not sure you will be able to trick passwd with the keybuffer tricks. There are ways to tell if the program is being run interactively, and no amount of keyboard games is going to fix this.

Sorry for the negative post, but good luck.
Dec 13 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

23
by: herrcho | last post by:
What's the difference between STDIN and Keyboard buffer ? when i get char through scanf, i type in some characters and press enter, then, where do the characters go ? to STDIN or Keyboard...
5
by: nx-2000 | last post by:
I've got a very large C# forms app and now that its being used in bigger environments we're getting a steady stream of "why does it do this?" problems. The most nagging of which right now is that...
0
by: rs | last post by:
Hi guys, I am trying to read from a USB keyboard using vb.net and HID classes. the USB keyboard is not my primary keyboard. I have a ps2 keyboard connected and is detected in device manager as...
2
by: rs | last post by:
Hi guys, I am trying to read from a USB keyboard using vb.net and HID classes. the USB keyboard is not my primary keyboard. I have a ps2 keyboard connected and is detected in device manager as...
1
by: NvrBst | last post by:
I'd like to simulate keypresses at the lowest level I can (writing to the keyboard buffer if possible). I can find x86 solutions but nothing for a higher level language. Does anyone know how I...
1
by: Damir | last post by:
Hallo everybody Does anyone knows how to access Keyboard buffer? At the moment I'm catching KeyDown event of the form, and waiting for carrige return or return key, but sometimes the Keyboard...
12
by: Sven | last post by:
Can someone point out source code for a safe circular buffer receiver transmitter? It's for sending and receiving bytes via RS232. Thanks in advance.
11
by: vbguy2008 | last post by:
Hi, I am coding a Windows Form Application in VB.NET 2008. I would like to clear the keyboard buffer or at least empty all outstanding key presses queued up for my application at certain points...
3
by: NaN | last post by:
I've been trying to use _kbhit() but it didn't do what I thought it would from books, "Detects whether a keypress is available for reading." Herbert Schildt says, "If the user has pressed a key,...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.