Register
It is currently Wed Nov 26, 2014 12:30 pm

open shell and execute several commands [SOLVED]


All times are UTC - 6 hours


Post new topic Reply to topic  [ 4 posts ] 
Author Message
 PostPosted: Thu Feb 24, 2011 1:44 am   
User avatar

Joined: Sat Jan 22, 2011 11:42 am
Posts: 7
Location: Ljubljana, Slovenia
Hello

I learned how to write a script to open a terminal and execute ONE command:
Code:
#!/bin/bash
gnome-terminal -e "mp3blaster --repeat --autolist /home/grom/muska.lst --playmode=allrandom"
exit

but, how do I execute several commands in same terminal?
Let us say, to:
-open terminal
-echo a line
-echo another line
-uptime
...
...
-and at the end to leave that terminal open?

if I do:
Code:
#!/bin/bash
xterm
echo "some text"

it opens terminal, but nothing is displayed... :(

Thank you.


Last edited by Seiduna on Fri Feb 25, 2011 8:35 am, edited 1 time in total.

Top
 Profile  
 PostPosted: Thu Feb 24, 2011 9:32 am   
Moderator
User avatar

Joined: Wed May 03, 2006 2:05 pm
Posts: 242
Hi Seiduna!

You will want to put it all on one line, after the "-e", or you could put it into a script and just run the script with "-e".

Code:
xterm -e "echo 'hello world'; sleep 2; echo 'hello again'; sleep 10"

# OR

echo "echo 'hello world'; sleep 2; echo 'hello again'; sleep 10" > test.sh
xterm -e sh ./test.sh


Keeping it open is a different problem... But if what you want is a bash prompt after the script is finished, try simply running your desired shell as the last command, like this:

Code:
xterm -e "echo 'hello world'; sleep 2; echo 'hello again'; sleep 2; /bin/bash -l"


I hope this helps!
-J


Top
 Profile YIM  
 PostPosted: Fri Feb 25, 2011 8:35 am   
User avatar

Joined: Sat Jan 22, 2011 11:42 am
Posts: 7
Location: Ljubljana, Slovenia
hello jeo,

Oh, man, it helped!!
Thank you!

So, basicly, I can not sent several commands, script-like-wise.
But I can make a execution of several commands, if I put them in one line,
as if I were doing with one.

And leaving it open at the end.. wow, great, thank you again!

I am really happy that I have found this forum!!!

Thank you and see you in next thread.


Top
 Profile  
 PostPosted: Fri Feb 25, 2011 10:50 am   
Moderator
User avatar

Joined: Wed May 03, 2006 2:05 pm
Posts: 242
Glad we could help! =D


Top
 Profile YIM  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP