bash - how to launch a console window via script and execute commands in it?
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
execute or run script in a new terminal bash or xterm.
even from a menu. I entered this into the fluxbox menu and a new terminal / bash window opens and the script is run - no need to even cd to the folder and seemingly no need for a & at the end either. the & symbol at the end is supposed to keep it running and then keep running the next commands when in a list of commands or a script. ie..
cd home/blabla/.runme1.sh &
cd mousepad /usr/blabla.txt &
sudo mousepad /etc/fstab
So the first 2 lines of this script will run the script and then move on to the next line but the 3rd line hasn't got the 'and' (&) symbol so waits until that command is complete until continuing.
how to pause script execution -- new problem, same project
Well, all worked out while I was using KDE3.5 and I was able to create the script I wanted.
Now all of a sudden, along comes KDE4.0 and my script won't work anymore, which seems strange to me, since presumably bash execution does not relate to the desktop software?
So, as far as I can tell, when I am running KDE4.0, this script does not "pause" to wait for the next command. That is, apparently the "odt" file is re-encrypted and removed before soffice actually executes.
Whereas, when I am running KDE3.5 I can unencrypt the file via gpg, the script launches OpenOffice to edit the file -- and waits until I exit OpenOffice to re-encrypt and remove the odt file.
How do I get my script to wait until one task completes before commencing the next task?
Anyway, here's my script:
#script to launch encrypted odt file
if [ -e "$1.odt" ]
echo "file exists"
echo "file don't exist"
konsole -e gpg -o $1.odt $1
if [ -e "$1.odt" ]
soffice -writer $1.odt
gpg -e -r client $1.odt
if [ -e "$1.odt.gpg" ]
mv $1.odt.gpg $1
echo "File did not encrypt!!!"
partially solved (launch terminal and execute via bash script)
Okay, I ran my script from another script that launches it in x-term. So, then I see an error that indicates a "session manager" failure and that bash failed to open a network socket. So, that would explain why the script simply forges ahead. This would seem to be a KDE4.0 problem, since I don't have the same thing in KDE3.0. Some other observations are that when I launch the script from the Dolphin file manager, everything runs extremely slowly (including OpenOffice save & exit). When I launch the script from the Konqueror filemanager, everything executes quickly. Just a bit of trivia someone else might be interested in.
I put a "read" command into my script, and so I can pause execution until a manual response.
But, this is not an elegant solution.
So, anyone with some better suggestions for automating the process?
Also, it's not clear to me why gpg will not open a dialog box when the script calls it without a terminal, but when I call gpg via a terminal command, then I get both an open terminal >and< a separate (more attractive) dialog box ...