LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Executing another script from xterm (https://www.linuxquestions.org/questions/programming-9/executing-another-script-from-xterm-596055/)

Chets 10-31-2007 07:26 AM

Executing another script from xterm
 
HI,
I am trying to execute another script from xterm using -e option.
but whenever i run xterm -e script-filename one window flashes and went off in sec.
don't know what is the problem here...

just to check this created a script which shows date,time and lists files
eg: date.sh:
#!/usr/bin/bash
echo `date`
echo `time`
exec ls

running this script from shell works fine.

but executing same script from xterm fails.
xterm -e date.sh --> pops up window and closes (window does not remains)

even tried with this xterm -e date.sh & --> same observation

need help in this, i want new terminal to remain and execute the script.

Hobbletoe 10-31-2007 08:22 AM

As soon as the last command executes, it is closing the window. Try a sleep statement if you want the window to remain up for a certain amount of time. You can also try putting a read statement at the end. That should make it wait for some user-input before closing.

gnashley 10-31-2007 08:38 AM

Ypu can alos use the -hold option which will keep the xterm open until you click it away.

bigearsbilly 11-01-2007 04:17 AM

try...

Code:

xterm -e ksh -c 'date && read'      # stay up until you press return
xterm -e ksh -c 'date && sleep 10'  # stay up 10 seconds

(or bash if you prefer of course)

Chets 11-01-2007 05:19 AM

Thank you all for ur response...

i got it what i need with -hold option.
eg:

xterm -hold -e /bin/bash date.sh

bigearsbilly 11-01-2007 05:40 AM

yes, but -hold is not standard xterm so it won't work on solaris, say


All times are GMT -5. The time now is 07:40 AM.