473,378 Members | 1,699 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,378 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 5207
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,...
1
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: 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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.