The UNIX Forums
"Join the Network of UNIX System Users"


 
Subject: calling a prg from the shell!!!
cldnails
Newbie
Rank: 1



UID 91
Digest Posts 0
Credits 0
Posts 44
Reading Access 10
Registered Apr 25, 2007
Status Offline
Post at Jun 6, 2007 08:48 AM  Profile | P.M. 
calling a prg from the shell!!!



calling a prg from the shell!!!




hi,

can somebody please answer my questions:

1) is the "sh" available on all unix systems at /bin/sh ???

2) how to make the following call working:

`which java` -cp $java_home myclass

since i do not know the location of java :-((


last edited by andy2000 : 3 weeks ago at 07:33 am.


Top
Celtik
Newbie
Rank: 1



UID 84
Digest Posts 0
Credits 0
Posts 62
Reading Access 10
Registered Apr 25, 2007
Status Offline
Post at Jun 6, 2007 08:48 AM  Profile | P.M. 
1) do ls -1 /bin/*sh
- this would probably list of shells available of your machine.

/bin/bash*
/bin/csh*
/bin/jsh*
/bin/ksh*
/bin/pfcsh*
/bin/pfksh*
/bin/pfsh*
/bin/remsh@
/bin/rksh*
/bin/rsh*
/bin/sh*
/bin/ssh*
/bin/tcsh*
/bin/zsh*


2)find out the java path on you machine,most of the times its under /usr/bin/java,else do a find for java

add that path (/usr/bin/java) to your path variable
once the path is set ,you dont have to say which java.

please search the forum of adding path to your shell .profile file


thanks
Top
bdumitru
Newbie
Rank: 1



UID 67
Digest Posts 0
Credits 0
Posts 20
Reading Access 10
Registered Apr 25, 2007
Status Offline
Post at Jun 6, 2007 08:48 AM  Profile | P.M. 
i think u did not understand my questions:

1) is the location /bin/sh a standard on all unix systems (aix, hp-ux, linux, sun ...)???



2) since i do not want to care where java located:
`which java` -cp $java_home myclass
Top
Eightrix
Newbie
Rank: 1



UID 132
Digest Posts 0
Credits 0
Posts 45
Reading Access 10
Registered Apr 25, 2007
Status Offline
Post at Jun 6, 2007 08:48 AM  Profile | P.M. 
from the unix specification:


quote:
applications should note that the standard path to the shell cannot be assumed to be either /bin/sh or /usr/bin/sh, and should be determined by interrogation of the path returned by getconf path , ensuring that the returned pathname is an absolute pathname and not a shell built-in.

for example, to determine the location of the standard sh utility:

command -v sh
Top
cool_78
Newbie
Rank: 1



UID 96
Digest Posts 0
Credits 0
Posts 17
Reading Access 10
Registered Apr 25, 2007
Status Offline
Post at Jun 6, 2007 08:49 AM  Profile | P.M. 
quote:
originally posted by andy2000
i think u did not understand my questions:

1) is the location /bin/sh a standard on all unix systems (aix, hp-ux, linux, sun ...)???



it is the standard location for a bourne-type shell; it may or may not be a posix shell


quote:
2) since i do not want to care where java located:
`which java` -cp $java_home myclass



if java is not in your path, then which (which is an unreliable command; there are at least two versions of it, one of which will not work in a bourne-type shell) will probably not find it.

if java is in your path, you don't need which, just use the command name.
Top
 

 

All times are GMT, the time now is Jul 31, 2010 03:34 AM

Powered by Discuz! 5.0.0  © 2001-2006 UNIX Forums
Processed in 0.005665 second(s), 8 queries

Clear Cookies - Contact Us - UNIX Help - Archiver - WAP