How run simple command in xterm, and leave open?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How run simple command in xterm, and leave open?
# 1  
Old 04-11-2011
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 it open, ideally for a fixed period of time (2 seconds for example)?

Here is the script if it helps -

Code:
#!/bin/bash
A=$(cat /proc/acpi/battery/BAT0/info | awk '/last full capacity/{print $4}') ;
B=$(cat /proc/acpi/battery/BAT0/state | awk '/remaining capacity/{print $3}') ; 

let C=$B*100/$A ; 
echo "$C%"

Thanks in advance

spoov
# 2  
Old 04-11-2011
Put a sleep 2 command in the script as the last thing. 2 seconds seems like a short time, but you can tweak the sleep command as you desire.
# 3  
Old 04-11-2011
try to add this line to the end of your script:

Code:
read -s -n1 -p "press any key to close..."

# 4  
Old 04-12-2011
Now i've had time to check, neither option works. I assumed one of them would but no. !

Must be something to do with the -e switch, it doesn't matter what command you put afterwards it seems only the first one gets run before the xterm closes.

If I run the script from a terminal I get the same behaviour (ie xterm opens then closes in a flash) but the command is also repeated in the running terminal.

Last edited by spoovy; 04-14-2011 at 03:49 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to run simple single command on multiple Linux servers?

Hi All, How can i run a single command on multiple servers with or without giving credentials. I have a file(servers.txt) which has got list of servers and i want to run a command lsb_release -dr on all these servers and get output of those servers against each server. I tried below code... (9 Replies)
Discussion started by: darling
9 Replies

2. Shell Programming and Scripting

Simple CEC run command on event script

To cut a long story short I need to implement a CEC server in order to allow my Samsung TV to interact with other peripherals. I plan on using a RPi for this purpose. I have installed CEC-untils and can run the tvservice monitor to look for HDMI events. I now need a simple script that will run... (3 Replies)
Discussion started by: barrydocks
3 Replies

3. AIX

Cannot open xwindows/xterm as a root

disabled the direct root login on all the AIX LPARs. So' only can become root by "su" to root from normal/regular user account. Issue is, I cannot open xwindows (xterm or xming) from my LPAR as a root. But I can open/access Xwindows using a USER account. />xclock Error: Can't open... (9 Replies)
Discussion started by: system.engineer
9 Replies

4. Solaris

Login/xterm and run script

Hi - I need to have a script run automatically when I login to my solaris 10 system (running CDE). I stuck this in my .cshrc file: xterm -e /bin/sh -c "/.script-name; exec /bin/sh" When I login, a window comes up and runs the iteractive script-name, and then when the script is done, my... (4 Replies)
Discussion started by: pyroman
4 Replies

5. Shell Programming and Scripting

Script for telnet and run one command kill it and run another command using while loop

( sleep 3 echo ${LOGIN} sleep 2 echo ${PSWD} sleep 2 while read line do echo "$line" PID=$? sleep 2 kill -9 $PID done < temp sleep 5 echo "exit" ) | telnet ${HOST} while is executing only command and exits. (5 Replies)
Discussion started by: sooda
5 Replies

6. Shell Programming and Scripting

How 2 run same command across all open terminals

Hi folks. This has been bothering me for a while. Among the 8 virtual desktops I'm using, I have 18 terminals open right now. I change some of my user configuration (e.g. put a new alias into ~/.bashrc); but in order to use this new added alias, I have to source the config file: .... (4 Replies)
Discussion started by: mirni
4 Replies

7. 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

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

Simple open remote file script

I use Rsync to copy files to a remote folder in a command like this rsync -aNPHAXxrvh --protect-args --fileflags --force-change --delete $file user@remotehost:/Volumes/backup That works great with passwordless key exchange ;) Now I'm trying to open a remote file using this command ssh -q... (5 Replies)
Discussion started by: elbombillo
5 Replies

10. Shell Programming and Scripting

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, --... (1 Reply)
Discussion started by: MROZ
1 Replies
Login or Register to Ask a Question