LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 08-14-2007, 02:05 PM   #1
hraposo
Member
 
Registered: Aug 2004
Posts: 370

Rep: Reputation: 30
Script run on xterm terminal, how?


I want create a script that it was executed in consoles of gnome, runs in a terminal xterm.
That is, the command for script could be ./script, in consoles of gnome, but later opens a xterm termina as root where script runs.
How I make this?
Which the commands to open xterm as root and to execute script?
 
Old 08-14-2007, 02:22 PM   #2
slakmagik
Senior Member
 
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Rep: Reputation: Disabled
What script? And why do you want this? For some things it's as simple as
Code:
#!/bin/sh
mrxvt -e vim "$@"
which I use as a wrapper on an some gui app that doesn't parse arguments correctly. This opens vim in mrxvt. But that's not really a 'script'. If you want a sequence of command lines to run in a separate terminal, maybe something like
Code:
if ! [ -f script_running ]; then
    touch script_running
    xterm -e $0
fi

if [ -f script_running ]; then
    ...actual script...
    rm script_running
fi
I have a feeling that's dumb way to do it (probably a really dumb way, as I'm having a brain-damaged day), but it's what occurs to me.

To run another terminal emulator, just invoke its name. To have it execute a command, for xterm and compatible (at least) the arg is '-e', as the man page says. To do it as root, you'll need to use 'su' or the like. Maybe sudo. I don't know of a reasonable way to su mid-script, so you can't './script' as a normal user and have it run as root.

Willing to be corrected here, though.

BTW, for an xterm and a command line script, you'll probably want the -hold argument. For a text-mode or GUI interface spawned from the script, that wouldn't be needed.

Last edited by slakmagik; 08-14-2007 at 02:35 PM. Reason: re-thought a bit
 
Old 08-14-2007, 04:46 PM   #3
hraposo
Member
 
Registered: Aug 2004
Posts: 370

Original Poster
Rep: Reputation: 30
Is almost...
The problem is that the script have 5 options, and when a option end the xterm close, but I want that it still open for the others choises. The script is not finish and is like that:

#############################################

#!/bin/sh
if ! [ -f script_running ]; then
touch script_running
xterm -e $0
fi

if [ -f script_running ]; then
...actual script...
rm script_running
fi
###################configuração alinex 2.0 beta########################################################
echo ESCOLHA A OPÇÃO?
echo "1 ) ACTUALIZAR SOURCE LIST."
echo "2 ) INSTALAR PROGRAMAS."
echo "3 ) CONFIGURAR O REDWRITE DOS DISCO ."
echo "4 ) INSTALAR DRIVERS NVIDIA ."
echo "5 ) SAIR ."
echo -n "Select an Option: "
read option
case "$option" in
1 )

#echo ISTO VAI CONFIGURAR O REPOSITÓRIO!
wget http://192.168.1.4/apache/software/l...alinex_2.0beta
mv /etc/apt/sources.list /etc/apt/sources.list_backtup
mv sources.list_alinex_2.0beta /etc/apt/sources.list
echo "deb http://ftp.br.debian.org/debian/ etch main contrib non-free" >> /etc/apt/sources.list
echo "deb http://packages.freecontrib.org/ubuntu/plf edgy-plf free non-free" >> /etc/apt/sources.list
echo "deb-src http://packages.freecontrib.org/ubuntu/plf edgy-plf free non-free" >> /etc/apt/sources.list
rm -rf sources.list_alinex_2.0beta
apt-get update
rm -rf /var/lib/apt/lists/ftp.br.debian.org_debian_dists_etch_main_binary-i386_Packages
rm -rf /var/lib/apt/lists/*.gpg
echo FIM, DE ACTUALIZAÇÃO

;;

2 )
echo INSTALAR ALGUNS PROGRAMAS E CODECS
apt-get install clamav realplay bluefish freespeak alltray filezilla gftp opera amsn mozilla-thunderbird liferea acroread brasero soundconverter mplayer gstreamer0.10-ffmpeg gstreamer0.10-gl gstreamer0.10-plugins-bad-multiverse gstreamer0.10-plugins-ugly-multiverse libxine-extracodecs w32codecs mplayer banshee sun-java6-jre sun-java6-fonts sun-java6-bin sun-java6-plugin sun-java6-jre sun-java6-fonts sun-java6-bin sun-java6-plugin gdesklets gdesklets-data mrxvtmrxvt-mini putty
wget http://www9.limewire.com/download/LimeWireLinux.deb
wget http://dl.google.com/linux/deb/pool/...rrent_i386.deb
#wget http://88.198.54.112/pub/getdeb/pd/p...tdeb1_i386.deb
wget http://web.telia.com/~u88005282/sum/....0.2-2_all.deb
wget http://dl.google.com/linux/deb/pool/...820-5_i386.deb
dpkg -i picasa_2.2.2820-5_i386.deb
dpkg -i LimeWireLinux.deb
dpkg -i google-desktop-linux_current_i386.deb
#dpkg -i pdfedit_0.3.1-1~getdeb1_i386.deb
dpk -i startupmanager_1.0.2-2_all.deb
rm -rf *.deb
wget http://192.168.1.4/apache/software/l...0060501.tar.gz
tar -vzxf all-20060501.tar.gz
mkdir /usr/lib/win32
mv ./all-20060501/* /usr/lib/win32
rm -rf *.tar.gz
rm -rf all-20060501
echo FIM, DA INSTALAÇÃO

;;
3 )

echo AGORA CONFIGURAR O REDWRITE DOS DISCOS
#get all user interaction done right away
echo "deb http://flomertens.free.fr/ubuntu/ edgy main main-al" >> /etc/apt/sources.list
echo "deb http://ntfs-3g.sitesweetsite.info/ubuntu/ edgy main main-all" >> /etc/apt/sources.list
echo "deb http://flomertens.keo.in/ubuntu/ edgy main main-all" >> /etc/apt/sources.list
wget http://flomertens.keo.in/ubuntu/givre_key.asc -O- | sudo apt-key add -
apt-get update
rm -rf /var/lib/apt/lists/ftp.br.debian.org_debian_dists_etch_main_binary-i386_Packages
apt-get install ntfsprogs libfuse2 fuse-utils ntfs-3g libfuse2 libfuse-dev pmount fuse-source automake fakeroot debhelper autotools-dev cdbs libsysfs-dev libhal-dev libhal-storage-dev intltool
echo 'feito'
wget http://heanet.dl.sourceforge.net/sou...e-2.7.0.tar.gz
tar zxvf fuse-2.7.0.tar.gz
cd fuse-2.7.0
./configure
make
make install
cd /home/helder/Desktop
rm -rf fuse-2.7.0
rm -rf *.tar.gz
echo "fuse" >> /etc/modules
modprobe fuse
gksu ntfs-config
echo "/dev/hda5 /media/hda5 ntfs-3g defaults,silent,user,auto,umask=0,locale=pt_PT.utf8 0 0" >> /etc/fstab
echo "/dev/hda1 /media/hda1 ntfs-3g defaults,silent,user,auto,umask=0,locale=pt_PT.utf8 0 0" >> /etc/fstab
umount -a
mount -a
pmount-hal /dev/hda1
pmount-hal /dev/hda5
mount -t ntfs-3g /dev/hda1 /media/hda1
mount -t ntfs-3g /dev/hda5 /media/hda5
apt-get upgrade
apt-get auto-remove
echo FIM,COMENTE AS ANTIGAS LINHAS DE HDA1 E HDA5 E FAÇA REBOOT


;;

4 )

echo VAMOS INSTALAR OS DRIVERS NVIDIA
wget http://albertomilone.com/ubuntu/nvid...buntu6_all.deb
dpkg -i envy_0.9.7-0ubuntu6_all.deb
apt-get install -f
rm -rf *.deb
envy -t
;;

5 )

exit 0
;;
esac
 
Old 08-14-2007, 08:12 PM   #4
slakmagik
Senior Member
 
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Rep: Reputation: Disabled
If I'm understanding what you want, just wrap your script in a while, like
Code:
while [[ $option != q ]]; do
  ...your script...
  q) exit ;;
done
That should bring up the menu repeatedly until the user enters 'q'.

Last edited by slakmagik; 08-14-2007 at 08:14 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to resize the xterm/terminal?? arroquant Linux - Newbie 4 02-15-2007 12:20 PM
Can double-click the shell script and choose "Run in Terminal" in Redhat? edwardsiow Programming 2 05-22-2006 08:56 PM
Xterm Terminal excidy Linux - Software 4 04-03-2005 10:01 PM
Help to create a script to open a terminal and run commands in it. Brian1 Linux - Software 6 02-07-2005 06:46 PM
Xterm Terminal Emulation DoubleOTeC Linux - Software 5 01-28-2005 08:35 PM


All times are GMT -5. The time now is 03:28 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration