How to send a Xterm command via a shell command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to send a Xterm command via a shell command
# 1  
Old 12-23-2008
How to send a Xterm command via a shell command

Hello,

I would like to send via a shell script a command to my XTerm.

For instance, I would like a shell script of mine to perform the command "clear-saved-lines()" to my Xterm.
Indeed, I don't want to use /usr/bin/clear but a command that erases everything in my xterm.

Thank you,

-- Marc
# 2  
Old 12-29-2008
You can have XTerm translate keystrokes into "actions". (See the man page, search for "Actions"). As an example, you'd add this to your X resource file:
Code:
*VT100*translations:    #override <Key>F11: clear-saved-lines()

That means that F11 will execute your function in the Xterm. How do you get such a key to Xterm? First, get the WindowID of your xterm. Then, use xvkbd:
Code:
windowID=`sine program`
xvkbd -text "\[F10]" -window $windowID

Does this get you closer to your solution?

Getting the WindowID is, well, it depends on your needs and it's not normally done from the command line. But several solutions exist. You can find these solutions described here and here.



Now it's possible to have a process send keystrokes into another X window.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need command to capture word from shell script and send email

Hello Experts, Greeting to all of you. I have a requirement, that we have a shell script status.sh that check the status of server and server status shows as status.sh Enterprise Server - Running Admin Server - Shutdown Requirement is like whenever the output shows shutdown it should... (2 Replies)
Discussion started by: aks_1902
2 Replies

2. Shell Programming and Scripting

Unable to pass send command in shell script

I am trying to automate a testcase . I am installing some software and it waits for user input after displaying "Do you want to continue ? " I am trying to do this in shell scripting. #!/bin/bash #!/usr/bin/expect -f /usr/bin/expect << EOF spawn apt-get install openjdk-7-jdk expect "*Do you... (1 Reply)
Discussion started by: Abdul Navaz
1 Replies

3. UNIX for Dummies Questions & Answers

How to send keyboard inputs toa UNIX command executed from a shell script?

I have a unix command that prompts for 'y'. How do I run this from my shell script? (4 Replies)
Discussion started by: Sree10
4 Replies

4. Shell Programming and Scripting

How run simple command in xterm, and leave open?

I have written a simple script to show battery life remaining. I would like to be able to quickly view it with a predefined keybinding or launcher. xterm -e scriptname should do the trick but the xterm closes when the script finishes, not giving me chance to read the output. How can I keep... (3 Replies)
Discussion started by: spoovy
3 Replies

5. UNIX for Dummies Questions & Answers

Running an xterm with a particular command in it

Hi guys i'm trying to run an xterm with a particular command in it. I have looked at the man page of xterm and it says to do this we use following command: -e program I want it to open the man page of the bash file. I tried xterm -e. It doesnt seem to work. I must be doing it... (1 Reply)
Discussion started by: Shyamz1
1 Replies

6. Shell Programming and Scripting

How can I send the input of a read line command through a shell script

Hi All, I wish to automate the unix command 'su' through a shell script. I would like to pass the content of a file as password to 'su' command. My script is as below, #! /bin/sh su userA while read line do rpm -ivh $line done < pwd.txt where pwd.txt contains the password of... (6 Replies)
Discussion started by: little_wonder
6 Replies

7. UNIX for Dummies Questions & Answers

xterm closing automatically after command excution

Hi, I have a commands in a file called commands.file, I am using this file with the following commnad xterm -e "commands.file" After executing this file in the new xterm, it is closing automatically. I want to use that xterm after that. Please help me regarding this? :) ... (4 Replies)
Discussion started by: chaitubek
4 Replies

8. UNIX for Dummies Questions & Answers

XTERM Command ????

All, Stuck with a XTERM issue ?? For some users, who are having execute permission (valid users), it's not showing the scroll bar in the GUI. Whereas for other invalid users( who do not have the execute permission) shows the scroll bar in the GUI. Confused ??? what could be the problem ?? Even,... (2 Replies)
Discussion started by: ronix007
2 Replies

9. Shell Programming and Scripting

awk/sed Command : Parse parameter file / send the lines to the ksh export command

Sorry for the duplicate thread this one is similar to the one in https://www.unix.com/shell-programming-scripting/88132-awk-sed-script-read-values-parameter-files.html#post302255121 Since there were no responses on the parent thread since it got resolved partially i thought to open the new... (4 Replies)
Discussion started by: rajan_san
4 Replies

10. UNIX for Dummies Questions & Answers

Correct switches for xterm command to make font larger

Dear Sirs Whenever I bring up an xterm window on my laptop running Mandrivia Linux, the font in the xterm window is so small that it is practically unreadable ! What switches do I need to use with the xterm command xterm -?? in order to make the font larger ? (3 Replies)
Discussion started by: kanejm
3 Replies
Login or Register to Ask a Question