How to execute a command in newly open terminal(gnome-terminal) in scripting ?

Donald Talbert donaldtalbert at gmail.com
Fri Jul 1 09:45:03 UTC 2011


On Fri, 2011-07-01 at 05:05 -0400, amritpal pathak wrote:
> 
> 
> On Fri, Jul 1, 2011 at 4:40 AM, Donald Talbert
> <donaldtalbert at gmail.com> wrote:
>         
>         On Thu, 2011-06-30 at 07:02 -0400, amritpal pathak wrote:
>         >
>         >
>         > On Thu, Jun 30, 2011 at 6:54 AM, Jordon Bedwell
>         <jordon at envygeeks.com>
>         > wrote:
>         >         On 6/30/2011 5:46 AM, Carl Friis-Hansen wrote:
>         >         > You might need to do it on the same line, like:
>         >         > gnome-terminal -e "ls -l"
>         >          it couldn't help.It is executing the command in
>         same terminal
>         >         even it is not opening new one despite
>         "gnome-termial" was
>         >         opening a new terminal at least.
>         >
>         >
>         >
>         >   Thanks
>         
>         
>         I might be mistaken on what your trying to accomplish but
>         heres a way to
>         do this. You will need to 'screen' package so type, then read
>         the man
>         page on it, very easy to use.
>         
>         sudo apt-get install screen
>          done.
>         Heres how you do this. (A snip of code from our scripts)
>         
>         screen -AdmS server /srv/serv/linux-start.sh
>         
>         you would type...
>         
>         screen -AdmS windowname directorytoscript-or-whatyouwanttorun
>           windowname is for what? 
>      is it user-choice to give a name what he wants?
>      windowname is name to new opened terminal?
> 
> 
>         screen is a very very useful program, be sure to read the man
>         page. Its
>          not hard to learn and will help you with bash shells.
>          
>      Thank you very much.
>       I am newbie to bash scripting.I tried your give code but it did
> not work.It again did not open a new terminal and even did not ran the
> last command.See the my code below.
>  May be i am wrong somewhere.
>  This is a a.sh file. 
>      
>   echo "what is your name"
> read b
> echo "your name is $b "
> screen -AdmS try sudo wget
> http://www.kannel.org/download/1.4.3/gateway-1.4.3.tar.gz
> 
> 
> 
> 
>         amritpalpathakgne.wordpress.com 

It ran, type 'screen -ls' you should see a screen labeled "try". 
With screen the 'd' flag means detach the screen so your script can
continue. So for a more desired effect maybe you could try removing the
d.

screen -AdmS try sudo wget
http://www.kannel.org/download/1.4.3/gateway-1.4.3.tar.gz

But I see what your trying to do now...

See if this does what you want it to... if it does feel free to remove
screen by typing 'sudo apt-get auto-remove screen'

gnome-terminal -e 'wget
http://www.kannel.org/download/1.4.3/gateway-1.4.3.tar.gz'

Let me know if this works for you.

Regards,
-Don

-- 
Donald Talbert <donaldtalbert at gmail.com>





More information about the ubuntu-users mailing list