forums.xandros.com Forum Index forums.xandros.com
Xandros User Forums
 
 FAQFAQ   SearchSearch   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How do I make a shell script to open a program?

 
Post new topic   Reply to topic    forums.xandros.com Forum Index -> Linux Devel 101
View previous topic :: View next topic  
Author Message
creations
Xplorer


Joined: 18 Mar 2005
Posts: 4
Location: Virginia, USA

PostPosted: Mon Mar 21, 2005 7:33 am    Post subject: How do I make a shell script to open a program? Reply with quote

I use Arachnophilia to edit my Webpage.

I download the .jar version of this to run on Xandros along with java jre files.

It all works fine with one exception - how do I create a shell script to open the program instead of going to the console and typing (?):

dcc@XANHLMRDD18:~/.Arachnophilia$ java -jar Arachnophilia.jar

I can open it fine doing this from the console once I've browsed to the folder - I just haven't figured out how to make a script to save the typing and file manager browsing time.

Any tips? Question Confused
_________________
S. Denison
Back to top
View user's profile Send private message Send e-mail
Andrew
Xendrosian
Xendrosian


Joined: 22 Feb 2003
Posts: 1739
Location: Wisconsin, USA

PostPosted: Mon Mar 21, 2005 8:01 am    Post subject: Reply with quote

This should work:

1. Open the text editor under Launch Applications |Accessories
2. Copy and pasts this in:

#!/bin/bash
java -jar ~/.Arachnophilia/Arachnophilia.jar

3. Save it as archnopilia.run in the .Arachnophilia directrory
5. In Xandros FIle Manager (XFM) right click on the archnopilia.run file and goto Properties
6. Click on the permissions tab and check th first "Exec" (to the right of "owner")
7. Now in XFM double click on the file
8. If it works you can put a shortcut on the desktop, or in the menu pointing to that file.

If that didn't work edit the archnopilia.run file (right click Open With |Text Editor) and change it to read:

#!/bin/bash
cd ~/.Arachnophilia
java -jar Arachnophilia.jar

and try again

any Question's just ask.

--Andrew
_________________
Registered Linux user number 316996
Back to top
View user's profile Send private message
pgk3734
Xplorer


Joined: 24 Jun 2004
Posts: 16

PostPosted: Tue Aug 16, 2005 2:06 am    Post subject: shell scripts Reply with quote

All you want to learn about:
www.linuxcommand.org
_________________
+++Registered Linux user #297797.
http://counter.li.org/.
Xandros 3.0, Mepis, Suse 9.1, Mandriva 2005, Windows XP.
Back to top
View user's profile Send private message
Chaotic Thought
Xandrosianding
Xandrosianding


Joined: 08 Jul 2005
Posts: 881
Location: Arlington TX

PostPosted: Wed Aug 17, 2005 11:44 am    Post subject: Reply with quote

The following does indeed work:

Andrew wrote:
#!/bin/bash
java -jar ~/.Arachnophilia/Arachnophilia.jar


However, I would recommend this instead:
Code:
#!/bin/bash
exec java -jar ~/.Arachnophilia/Arachnophilia.jar


The exec command instructs bash not to remain in memory, so using exec when possible is more efficient.
Back to top
View user's profile Send private message
Andrew
Xendrosian
Xendrosian


Joined: 22 Feb 2003
Posts: 1739
Location: Wisconsin, USA

PostPosted: Tue Aug 23, 2005 5:46 pm    Post subject: Reply with quote

Quote:
The exec command instructs bash not to remain in memory, so using exec when possible is more efficient.


I'm not disagreeing with you, but, what does that mean? why do we want bash to remain in memory, and if it does, why is it more efficient?

--Andrew
_________________
Registered Linux user number 316996
Back to top
View user's profile Send private message
Chaotic Thought
Xandrosianding
Xandrosianding


Joined: 08 Jul 2005
Posts: 881
Location: Arlington TX

PostPosted: Tue Aug 23, 2005 5:53 pm    Post subject: Reply with quote

No, using exec means that bash does not remain in memory. It's not a huge deal if it does, to be sure. But to keep the system tidy, it's a good idea to use exec for wrapper scripts such as these. Another subtle thing (but it can be important in some cases) is that using exec does not create a new process in the process table; it just replaces the current bash process with the new program.

For example, here's what my process tree looks like when I'm running bash from gnome-terminal:
Code:
chaotic@VAIO:~$ pstree $(pidof gnome-terminal)
gnome-terminal─┬─bash───pstree
               └─gnome-pty-helpe


Now, if I launch bash a few times,
Code:
chaotic@VAIO:~$ bash
chaotic@VAIO:~$ bash
chaotic@VAIO:~$ bash
chaotic@VAIO:~$ bash
chaotic@VAIO:~$ bash
chaotic@VAIO:~$ pstree $(pidof gnome-terminal)
gnome-terminal─┬─bash───bash───bash───bash───bash───bash───ps+
               └─gnome-pty-helpe


Now it is much messier. You can think of those five bash processes as five programs that you launched with wrapper scripts; each one would have a bash as its parent in the process tree, so that 5 programs launched by wrapper scripts would have at least 10 processes. Now, let's try that again with exec:
Code:
chaotic@VAIO:~$ pstree $(pidof gnome-terminal)
gnome-terminal─┬─bash───pstree
               └─gnome-pty-helpe
chaotic@VAIO:~$ exec bash
chaotic@VAIO:~$ exec bash
chaotic@VAIO:~$ exec bash
chaotic@VAIO:~$ exec bash
chaotic@VAIO:~$ exec bash
chaotic@VAIO:~$ pstree $(pidof gnome-terminal)
gnome-terminal─┬─bash───pstree
               └─gnome-pty-helpe
chaotic@VAIO:~$


Notice that using exec does not create a new process; it just re-uses the current one. So by using this, each of the programs launched by your wrapper scripts only shows up once in the process table, and it stands on its own in the process table, rather than appearing as a child of bash.
Back to top
View user's profile Send private message
Andrew
Xendrosian
Xendrosian


Joined: 22 Feb 2003
Posts: 1739
Location: Wisconsin, USA

PostPosted: Tue Aug 23, 2005 7:08 pm    Post subject: Reply with quote

I see, thank you.
_________________
Registered Linux user number 316996
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.xandros.com Forum Index -> Linux Devel 101 All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
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 vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group