Sending keystrokes to another process


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Sending keystrokes to another process
# 1  
Old 01-24-2012
Sending keystrokes to another process

The third-party ERP system used by our company has no idle-out facility and we sometimes have issues because users simply walk away from their computers and leave sessions logged in for hours or even go home without logging out. (We are in a factory environment so it is hard to raise the care factor very high in the users - once the siren goes for clock-off they're out of there!) Too many sessions and we run out of licences, and worse there are overnight processes that can cause data corruption if there are any logged in sessions. Currently I have a crude method of killing any sessions before the overnight processes start but sometimes even that can cause data corruption.

The solution is so tantalisingly close and yet, I suspect, so far. Every screen and every menu is backed out of by simply pressing a Function key which sends the string "end" and a carriage return to whatever field is awaiting input. I could have a continuously running script that uses a "finger" command or something similar to detect sessions that have been idle for say an hour. Then if I could just keep sending the "end" string to that process until it eventually logged out my problem would be solved.

I have tried coming at this from a few different angles but keep hitting dead ends. Does anybody have any suggestions for how I can send keystrokes to an existing process and have it react to them? Can a process take input from two sources (i.e. from the keyboard and from my script)?

Thanks

Wayne

SCO_SV notmyrealhostname 5 6.0.0 i386
# 2  
Old 01-24-2012
It matters what the interface for the user is.
If it is console, root can write to what the process sees as /dev/tty, the controlling terminal. If it is an ncurses app the same is likely true.

If it is x (windows-like) you have to send key_events to the window. Which is harder because it involves C code.

I'm vague because you need to supply a lot more information.
1. are they ssh sessions, pty's, X? Precisely what connect. be detailed.
2. are they distributed sessions on local servers?
3. can you currently trace a pid on unix back to a user terminal, whatever that is?

I'm not SCO, but some folks here are. However a lot of terminal stuff is common throughout UNIXes. So can probably help in some instances.
# 3  
Old 01-24-2012
In addition to what Jim asked, what is the client side environment?
Are you running out of SCO user licenses, or application software licenses?
Does killing a process always result in the loss of an application software license? is there a way to force a recount of in use licenses?

---------- Post updated at 01:30 PM ---------- Previous update was at 09:02 AM ----------

You might be able to accomplish this by using expect.
# 4  
Old 01-24-2012
Please show us your process for killing database clients.
If anywhere in your process a unix "kill -9" appears, the process needs urgent change.

If you know, please post the brand name of the Database Engine used by your ERP system.

We need to know if this is a client-server system or something simple like telnet access. If it is telnet access then something like a "kill -15" to the telnet session is usually sufficient to cause a "hangup" state which disconnects the session tidily (as if the user had powered down their terminal).

Last edited by methyl; 01-24-2012 at 05:33 PM.. Reason: typos
# 5  
Old 01-24-2012
Thanks for the responses everybody. I'll try and answer all the questions from each of you here:
  • The interface is what I would call a "terminal" interface - using more or less a telnet connection. (Specifically, AppGen PowerWindows 5.1.)
  • They are not ssh sessions and not X-Windows (like), so I guess that means they're pty's. A who command returns this:
chrislon ttyp1 Jan 25 06:00
and a finger command returns this:
chrislon Chris Longbottom *p1 Wed Jan 25 06:00 w00215.notmyrealcompany.com
  • I'm not sure what a distributed session on a local server is, but I think the answer would be "no".
  • I can currently trace a pid on unix back to a user terminal.
  • We have 40 SCO user licenses and 40 application software licenses, so I guess we run out of both. (To be honest it's a while since I've seen the error message so I can't recall whether it looks like an OS message or not.)
  • Hmm...I never thought about whether killing a process would result in the loss of an application software license - I was only concentrating on the fact that it frees up a SCO license. I'll have to investigate this one further.
  • Wow, the "expect" command looks very interesting! I have to go through that man entry thoroughly to get a grip on it. Unix is amazing - I've been using it for scripting etc since 1985 (on and off) and I've never come across the expect command. I'm sure it's one of the more modern commands but it just shows there's still "buried treasure" out there. Smilie
  • My process for killing the clients is this:
kill `ps -o pid= -u "\`echo \\\`who | egrep -v "root|dharma|wayne" | cut -d' ' -f1 | sort -u\\\`\`"` `lsof 2>/dev/null | fgrep "sqlnw->" | awk '{print $2}'` 2>/dev/null
sleep 5
kill -9 `ps -o pid= -u "\`echo \\\`who | egrep -v "root|dharma|wayne" | cut -d' ' -f1 | sort -u\\\`\`"` `lsof 2>/dev/null | fgrep "sqlnw->" | awk '{print $2}'` 2>/dev/null
sleep 5
  • The base (non-relational) database engine is Appgen with an ODBC engine named Dharma.
I hope this covers all you need to know.

Thanks

Wayne
# 6  
Old 01-24-2012
Appgen is not a typical terminal emulation product. What does the user .profile look like.
I used to use a similar approach to killing sessions, but ended up changing to using "/etc/fuser" instead. Assuming all the data files are in one directory,
Code:
/etc/fuser  /u/data/*  2>files_checked 1>pid_numbers

"pid_numbers" contains a list of processes using files in the /u/data directory.

Last edited by jim mcnamara; 01-25-2012 at 08:49 AM..
# 7  
Old 01-25-2012
Hi jgt,

I have used fuser before and I guess I hadn't thought to use this method to get a "cleaner" list of processes specifically using the ERP system. Unfortunately the data files are not all in one directory although they are broken into module subfolders only one level deeper so it's probably still doable. Ultimately though I'm trying to get away from killing altogether.

The .profile is shown below.

Thanks

Wayne

----------

AGINIT="FORMSPOOLER='lp -dlp'SPOOLER='lp -ddadmdot'AGDATE='I'";export AGINIT
AGPWD=/etc
AGHOME=/u/timms
AGAUTOR=ON
AQLHELP=/u/timms/AQLHELP
PDEFPTH=/u/timms
SSPATH=/u/timms/SS
export AGPWD AGHOME AQLHELP PDEFPTH SSPATH AGAUTOR
PATH=:.:/bin/sh:$AGHOME/bin:/usr/chrislon:$PATH;export PATH
cd $AGHOME
trap '' 2 3
clear
TERM=vt220;export TERM
AGCLIENT=Y;export AGCLIENT
run sm
trap '' 2 3
exit
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

Identify process sending ldap requests to old DNS server

Hi, I have a Solaris 10 system, which appears to be sending out LDAP queries to a server that is due to be decomissioned. Is there a way to identify which process is sending out these queries? The problem is that the local port constantly changes, and the connections do not stay open long... (3 Replies)
Discussion started by: badoshi
3 Replies

2. Shell Programming and Scripting

SEnding a process to backgorund (&) in here document

Trying to do the following ssh root@192.168.0.111 'bash -s' <<ENDSSH mkfifo a.pipe gzip -c < a.pipe > aa.gzip & ENDSSH it does not seems to be able to send the gzip process to background. (3 Replies)
Discussion started by: acelau
3 Replies

3. Shell Programming and Scripting

Record and re-use keystrokes

We have a FORTRAN program that creates a report for our client. The client makes a number of selections as to what will appear on the report. However, the client has to repeat this everytime the report is run. I am trying to find a way to record what they've selected (their keystrokes) in UNIX and... (22 Replies)
Discussion started by: KathyB148
22 Replies

4. OS X (Apple)

Any mac software for recording keystrokes

I'm trying to find a good keylogger that doesn't come with any viruses. It happens to me several times that my browser crashes when I am in article writing or some other thing, very annoying. Thus, I need a keylogger to keep all my keystroke recorded. I 'v tried some, like the Aobo Mac Keylogger,... (1 Reply)
Discussion started by: Bluerosen
1 Replies

5. UNIX for Dummies Questions & Answers

Sending signal from child to parent process!

Hi All, I facing a problem in handling signals between parent process communication. I am trying to send a signal(SIGINT) from child to parent. I am using kill function to do so and I am trying to read the signal using sigaction(). But the program is ending abruptly and I am not able to figure out... (4 Replies)
Discussion started by: vkn_1985
4 Replies

6. Shell Programming and Scripting

sending email as background process

Hi All, Solaris Bash v3x I have a script that accepts an error code, and if the error code is not 0 then an email is sent using mailx to details the error. I want to be able to implement the functiuonlity whereby i can send the email in a background process so the script can continue with... (3 Replies)
Discussion started by: satnamx
3 Replies

7. Shell Programming and Scripting

Queueing keystrokes

Hello, I have a ksh which can be run interactively with read etc waiting for input and so forth. Do you have an idea how can I invoke the ksh and supply a sequence of keystrokes that will feed the executable flow so that it will automatically run as if someone actually walked through one prompt... (7 Replies)
Discussion started by: gio001
7 Replies

8. Shell Programming and Scripting

Issue in mail sending process

Hi I created one CSV file and i need to append some message in the content of my mail. $sales=sales.dat $sales_csv=sales.csv $sales_report=sales.txt this is the command am using it. echo "sales for `date`"| read subject uuencode $sales $sales_csv | mailx -ms "${subject}."... (2 Replies)
Discussion started by: bobprabhu
2 Replies

9. UNIX for Dummies Questions & Answers

recording keystrokes in vi

What is the syntax for recording command in vi. If I want to repeat a command over and over. My file is 12/01/05,,adsmte,9,0,0 12/02/05,,adsmte,12,0,0 12/03/05,,adsmte,10,0,0 12/04/05,,adsmte,11,0,0 12/05/05,,adsmte,10,0,0 12/06/05,,adsmte,10,0,0 12/01/05,,tsmpc1,57,1,2... (5 Replies)
Discussion started by: reggiej
5 Replies

10. UNIX for Dummies Questions & Answers

Sending Emails to a unix process

Hi , I need to have a unix process which is setup to read all incoming mail for some user and process the same. How tough it is to code the same.Is there any way that we can download some shell scripts for the same from some internet site Kindly help. (2 Replies)
Discussion started by: xsriniva
2 Replies
Login or Register to Ask a Question