Error Running jar command from shell Script - shell

I need to Extract the contents of the Jar in to a specific location. When I run the below command to extract jar,it works correctly.
jar -xf location/ex.jar
The same command I placed inside a script(.sh/.ksh).When I run the script, I get the below error :
jar: not found.
Both the user are same from which I run the script/command. I am using AIX server.
Thanks for Your help.

Your PATH variable isn't set correctly.
Find your java installation : find / -name "java"
Add the correct path to your PATH variable : export PATH="$PATH:/location/to/java/jre/bin"
Or, just use unzip /location/ex.jar

Related

Command not found in ssh but is in direcory

I am using an ssh account that connects to an external server, i have downloaded through guix some software like samtools and bedtools but when i try to use them in my directory it gives me this error:
-bash: samtools: command not found
In my direcory, however, there is the directry guix.profile and if I go into the bin folder of this, I have everything I downloaded.
What am I doing wrong?
Thank you
enter image description here
To run a file from the shell you need two things:
The shell must find the file
Being in the same directory does not enable the shell to find the file. You have to either supply an absolute or relative path the file, or have the directory in your PATH environment variable
In simplest terms this means instead of
$ samtools
try
$ ./samtools
The relative path tells the shell it wants that file
To run it from another directory, either use the whole absolute path, e.g. /home/yourname/samtools , or move the file into a directory that is on your $PATH
The file needs to be executable
If the file is not executable you will need
$ chmod +x ./samtools

Getting full name of file after scp - batch script

Hello I'm trying to make a simple .bat file, I'm trying to modify a file after downloading it from another machine.
The problem is the python script needs the full name of the file, so filename* won't work so is there a way to download a file via scp and then somehow assign the downloaded file a variable so the script can find the full name
scp user#192.168.1.X:"C:\Users\user\Downloads\filename*" ./
pythonscript.py filename*
pythonscript.py "%cd%\filename"

How to invoke a groovy file ( filename.groovy ) or groovy script via shell script?

Same groovy file can be invoked by .bat file as :
java -cp lib/groovy-all-2.4.6.jar;lib/ivy-2.4.0.jar;. groovy.ui.GroovyMain PostBuild.groovy
Need to perform same operation but via Shell Script or any.sh file on Linux
"Could not find or load main class groovy.ui.GroovyMain" : This indicates that java was launched but groovy-all-2.4.6.jar was not found from classpath.
Here's a couple hints:
Check that you replaced semicolon ; with colon : in your -cp parameter.
When you give lib/groovy-all-2.4.6.jar in your -cp parameter, java
assumes the lib directory (with groovy jar) exists in current
directory. Note that current directory is not (necessarily) the
directory where the shell script is, but it's the directory where you
are when you launch that script (unless you explicitly change current
dir within the script).
Check that groovy-all-2.4.6.jar exists in lib subdirectory under
current directory and the script executing user has read rights in
that directory and jar files.

Add to PATH based on a Jenkins build parameter

I have a Jenkins (Windows / C++) project that is failing because some DLL's are not found on the PATH. I know I can use the EnvInject plugin to update the PATH, but all the examples I found suggest to use a hard-coded folder. I want to add a folder that is specified as a build parameter. How do I do that?
You could add to PATH in withEnv:
node {
withEnv(["PATH+LIBS=${params.newPath}"]) {
sh 'echo $PATH'
}
}
The will prepend the specified path to the $PATH variable in external scripts (i.e. sh).
One thing you could do is, define your path to add to the PATH variable, as a string build parameter, and then, as a build step (likely the first step in your case), execute the following batch command:
set PATH=%PATH%;%MY_BUILD_PARAM%
echo %PATH%
The echo command is just to confirm it works

How to parse shell script output in maven

I run a unixODBC installation script in a maven pom.xml file and it has the following output.
Run the command 'cd /tmp/unixODBC.30048.28312.21379/unixODBC-2.3.0; make install' to install the driver manager.
How do I capture the text inside the '' above, e.g., cd /tmp/unixODBC.30048.28312.21379/unixODBC-2.3.0; make install, and then execute it? The /tmp/unixODBC* directory name changes everytime.
you could pipe your maven output to
mvn ...|grep -oP "(?<=')[^']*(?=')"|sh
without the ending |sh you could check if the captured the commands chain correct.

Resources