Re: [CentOS] explain strange behavior

2016-08-19 Thread Jon LaBadie
On Fri, Aug 19, 2016 at 01:12:57PM -0500, Dan Hyatt wrote:
> In my bin directory, most of the binaries are linked to it. It is in my
> path. I have googled this and cannot find anything close.
> 
> I am running bash on centos6.8
> 
> When I run   "which command" most of the files in this custom bin directory
> show up.
> 
> When I run "which file.jar" it cannot see it, but I can *ls* the file  (soft
> link)
> 
> as which only works on executables (according to man page), I created a
> dan.jar empty file and did a which on dan.tar and found it.
> 
> 
> can anyone explain what is happening and how I can soft link the jar files
> to my bin directory so which can see them?
> 
I don't use java, so this may be way off base.

I'm assuming you have several *.jar files, but will work with two,
foo.jar and bar.jar.

Place all your jar files in a single directory, not bin. Under lib
is the common place.  I'll use /home/dan/lib/jarfiles.

In your bin directory place a shell script named "foo" containing
something like this:

  #!/usr/bin/bash

  ProgName=${0##*/} # (basename) strips dirs from path
  JarDir=/home/dan/lib/jarfiles
  JarFile=${JarDir}/${ProgName}.jar

  ## possibly test for existance of jar file

  java -jar ${JarFile} "${@}"# I assume there may be args to pass.

That would let you run foo.jar as "foo" and do a "which foo" as it is
an executable shell script.

For bar.jar you merely need to put it in the JarDir and make a link
in the bin directory:

  ln /home/dan/bin/foo /home/dan/bin/bar

Do the same for each *.jar, move to JarDir, make a link.

If particular jar files need special treatment you can put a switch
statement in the script based on $ProgName.

Jon
-- 
Jon H. LaBadie j...@jgcomp.com
 11226 South Shore Rd.  (703) 787-0688 (H)
 Reston, VA  20190  (703) 935-6720 (C)
___
CentOS mailing list
CentOS@centos.org
https://lists.centos.org/mailman/listinfo/centos


Re: [CentOS] explain strange behavior

2016-08-19 Thread Valeri Galtsev

On Fri, August 19, 2016 1:12 pm, Dan Hyatt wrote:
> In my bin directory, most of the binaries are linked to it. It is in my
> path. I have googled this and cannot find anything close.
>
> I am running bash on centos6.8
>
> When I run   "which command" most of the files in this custom bin
> directory show up.
>
> When I run "which file.jar" it cannot see it, but I can *ls* the file
> (soft link)

Do these files that are not shown by which command have "execute" bit on
for everyboty (in other words, can regular user executing the command
"which" execute that file, and read that file: what is set in UNIX
permissions for that file.

Showing us what

ls -l /usr/local/bin/file.jar

(if it is symlink, show us permission of actual file symlink points to)

Valeri

>
> as which only works on executables (according to man page), I created a
> dan.jar empty file and did a which on dan.tar and found it.
>
>
> can anyone explain what is happening and how I can soft link the jar
> files to my bin directory so which can see them?
>
> Dan
>
>
>
> ___
> CentOS mailing list
> CentOS@centos.org
> https://lists.centos.org/mailman/listinfo/centos
>



Valeri Galtsev
Sr System Administrator
Department of Astronomy and Astrophysics
Kavli Institute for Cosmological Physics
University of Chicago
Phone: 773-702-4247

___
CentOS mailing list
CentOS@centos.org
https://lists.centos.org/mailman/listinfo/centos


Re: [CentOS] explain strange behavior

2016-08-19 Thread John R Pierce

On 8/19/2016 11:12 AM, Dan Hyatt wrote:
In my bin directory, most of the binaries are linked to it. It is in 
my path. I have googled this and cannot find anything close.


I am running bash on centos6.8

When I run   "which command" most of the files in this custom bin 
directory show up.


When I run "which file.jar" it cannot see it, but I can *ls* the file  
(soft link)


as which only works on executables (according to man page), I created 
a dan.jar empty file and did a which on dan.tar and found it.



can anyone explain what is happening and how I can soft link the jar 
files to my bin directory so which can see them? 


`which` will only show files that have chmod +x  set and are in the path.

jar files aren't directly executable by the shell, you have to run java 
-jar name.jar to execute them, so there's no point in having them in the 
path or +x.



--
john r pierce, recycling bits in santa cruz

___
CentOS mailing list
CentOS@centos.org
https://lists.centos.org/mailman/listinfo/centos


[CentOS] explain strange behavior

2016-08-19 Thread Dan Hyatt
In my bin directory, most of the binaries are linked to it. It is in my 
path. I have googled this and cannot find anything close.


I am running bash on centos6.8

When I run   "which command" most of the files in this custom bin 
directory show up.


When I run "which file.jar" it cannot see it, but I can *ls* the file  
(soft link)


as which only works on executables (according to man page), I created a 
dan.jar empty file and did a which on dan.tar and found it.



can anyone explain what is happening and how I can soft link the jar 
files to my bin directory so which can see them?


Dan



___
CentOS mailing list
CentOS@centos.org
https://lists.centos.org/mailman/listinfo/centos