LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-07-2008, 05:17 PM   #1
musther
Member
 
Registered: Sep 2007
Posts: 36

Rep: Reputation: 15
Bash script - call xterm and run in it.


I have a script which my users are most likely to run from Nautilus just by double clicking and selecting run.

However, I want the script to run in a terminal to interact with the users through an xterm window.

So I basically need the script to start xterm and then run the remainder of itself in that xterm window.

I know I can execute a command or two with:

Code:
xterm -e "command"
But the script is reasonably long.

Is there any way to do this short of creating two scripts?

Thanks
 
Old 02-07-2008, 05:25 PM   #2
jailbait
LQ Guru
 
Registered: Feb 2003
Location: Virginia, USA
Distribution: Debian 12
Posts: 8,337

Rep: Reputation: 548Reputation: 548Reputation: 548Reputation: 548Reputation: 548Reputation: 548
Quote:
Originally Posted by musther View Post
I have a script which my users are most likely to run from Nautilus just by double clicking and selecting run.

However, I want the script to run in a terminal to interact with the users through an xterm window.

So I basically need the script to start xterm and then run the remainder of itself in that xterm window.

I know I can execute a command or two with:

Code:
xterm -e "command"
But the script is reasonably long.

Is there any way to do this short of creating two scripts?

Thanks
I do this routinely by creating two scripts. I don't see anything wrong with doing so. The first script is:

xterm -e /pathname/commandname

and the second script is in /pathname/commandname

----------------------
Steve Stites
 
Old 02-08-2008, 07:57 PM   #3
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,781

Rep: Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081
Quote:
Originally Posted by musther View Post
Is there any way to do this short of creating two scripts?
Thanks
If you really want to do it one script you could have something like this

Code:
#!/bin/sh

if [ "$RUNNING_IN_NEW_XTERM" != t ] ; then
        RUNNING_IN_NEW_XTERM=t exec xterm -e "$0 $*"
fi

#rest of the script here...
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
export call in bash script Donald1000 Linux - Software 10 03-12-2009 08:03 PM
Script run on xterm terminal, how? hraposo Linux - General 3 08-14-2007 08:12 PM
Run Bash Script @ login XaViaR Linux - General 5 01-26-2006 10:05 PM
Asking a C program to call a bash script sceadu Programming 4 07-28-2005 08:52 PM
how to run one bash script from within another? babag Programming 9 04-28-2005 12:12 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:00 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration