jar -tvf hello.war
However, my .war also contains some .jar in a lib folder within the .war.
I need a command display the contents of all the .jars within the .war.
The reason I need command line and not use tools like Winrar is because I need to incorporate it in my UNIX shell script.
You can do this with a short script.
TEMPDIR=`mktemp -d`
REALPATH=`pwd`/$1
(cd $TEMPDIR && jar xf $REALPATH)
for j in `find $TEMPDIR -name "*.jar"`; do echo `basename $j`; jar tvf $j; done
rm -rf $TEMPDIR
E.G.
$ ./go.sh x.war
z.jar
0 Sat Jul 30 21:53:20 EST 2011 META-INF/
71 Sat Jul 30 21:53:20 EST 2011 META-INF/MANIFEST.MF
182 Sat Jul 30 21:52:54 EST 2011 go.sh
25 Sat Jul 30 21:50:46 EST 2011 zz.sh
x.jar
0 Sat Jul 30 21:33:28 EST 2011 META-INF/
71 Sat Jul 30 21:33:28 EST 2011 META-INF/MANIFEST.MF
0 Sat Jul 30 21:33:20 EST 2011 x
Not really useful in a shell script, but the easiest way I've found to do this when looking at webapps interactively is to open them in emacs; archive mode understands jars, and just needs to be told about .wars, by adding
(add-to-list 'auto-mode-alist '("\\.war\\'" . archive-mode)) to your .emacs. Then you can open the war like a normal directory, plus anything insde it:
Related
I connect to a remote computer thru VNC and use Konsole for my work. Konsole is version 2.3.3 using KDE 4.3.4. I have these two aliases:
alias ll 'ls -haltr; pwd'
alias cd 'cd \!*; ll'
which I observed to have the following behavior:
When path exists, it will cd to it and also do the ll alias
When path doesn't exist, it will simply say the path doesn't exist and won't do the ll anymore
Example:
Path exists
[10] % cd foo
total 14K
-rw-r----- 1 user group 913 Jun 3 2014 readme
-rw-r----- 1 user group 1.2K Dec 3 2020 report.txt
drwxr-x--- 2 user group 4.0K Jan 12 17:50 ./
drwx------ 77 user group 8.0K Jun 24 11:57 ../
/home/user/foo
[11] %
Path doesn't exist
[10] % cd nowhere
nowhere: No such file or directory.
[11] %
Now our department has transferred to another division and we've just started to connect remotely thru Exceed TurboX. I still use Konsole but the version is now 2.10.5 using KDE 4.10.5. I copied over the same two aliases, but I'm now observing a different behavior:
When path exists, it will cd to it and also do the ll alias (basically same as #1 above)
When path doesn't exist, it will attempt to cd AND still do the ll (different as #2 above)
So for #2, here's how it looks like:
[10] % cd nowhere
nowhere: No such file or directory.
total 120K
-rw-r----- 1 user group 272 Jan 6 2021 .cshrc
-rw-r----- 1 user group 1.2K Jan 6 2021 .alias
drwxr-x--- 2 user group 4.0K Jan 12 17:50 ./
drwx------ 77 user group 8.0K Jun 24 11:57 ../
/home/user
[11] %
I would like to know how to get behavior #2 of the previous working environment to this current working environment.
I've added the information on the Konsole and KDE versions because if the behavior is due to the version and there's no workaround, then I'll just be sad for the rest of my life working in this new remote desktop env. ^_^
I'm currently exploring a "check first if the path exists before doing ll" but to no avail. :'(
Edit:
The shell I'm using is tcsh
% printenv SHELL in both environments showed /bin/tcsh
And in addition:
Old environment
% echo $version
tcsh 6.17.00 (Astron) 2009-07-10 (x86_64-unknown-linux) options wide,nls,dl,al,kan,sm,rh,color,filec
New environment
% echo $version
3
The information in the question is still not sufficient to find out why tcsh behaves differently in the two working environments.
The alias defines a sequence of commands (cd followed by ll) without any condition.
alias cd 'cd \!*; ll'
On one system the execution of the alias seems to stop if the cd command reports an error for currently unknown reasons.
The correct way to prevent the execution of ll after a failed cd command would be the conditional execution of the ll command, e.g.
alias cd 'cd \!* && ll'
The decade long advice is: do not use aliases, use functions.
ll() { ls -haltr "$#" && pwd; }
cd() { cd "$#" && ll; }
Maybe this question is too broad (I hope not) but I'm currently don't know, how to solve my WordPress Git Branching Model problem.
My plan was to create a branching model like this without using a BitBucket Server or Jenkins:
So I've started making a git init in the wp-content folder of my PROD (at this time only installation of WP) system.
After I was done with this, I've cloned the whole PROD page and created a staging subdomain. After cloning was completed, I've deleted the wp-content folder at the staging system and typed in a git clone <prod-path>/.git.
This worked great and after doing some changes (for testing purposes) at the staging version, I was able to push them back to the PROD. Until now, everything is logic and normal and worked very well.
After thinking some time, I've got the great (maybe stupid) idea, to do the same with a local DEV clone on my PC. So I've did the same like at the staging version before, but this time, I've cloned the staging wp-content clone (PROD clone) to my local DEV version.
For the first view, everything looked fine but after trying to push something to the Staging system, I've got rejected from the target staging Git:
remote: error: refusing to update checked out branch: refs/heads/development
remote: error: By default, updating the current branch in a non-bare repository
So I first thought, that it's very stupid what I did, because the staging is also a clone without a HEAD like on the PROD (I think).
So my question to you:
Do you have an idea, how I can keep this kind of Workflow without any 3rd party software, but with 2 clones that I can work on DEV, test on Staging and going live on PROD?
To say it with commands:
1. git push <to the staging>
2. git push <to the prod>
3. git merge <dev to master>
Update
This is the content of my bare hooks folder (there is no post-received, what should I do?):
/wp-content/.bare/hooks$ ls -la
total 56
drwxr-xr-x 2 wp_ftp psacln 4096 Apr 11 13:09 .
drwxr-xr-x 7 wp_ftp psacln 4096 Apr 11 13:20 ..
-rwxr-xr-x 1 wp_ftp psacln 478 Apr 11 13:09 applypatch-msg.sample
-rwxr-xr-x 1 wp_ftp psacln 896 Apr 11 13:09 commit-msg.sample
-rwxr-xr-x 1 wp_ftp psacln 3327 Apr 11 13:09 fsmonitor-watchman.sample
-rwxr-xr-x 1 wp_ftp psacln 189 Apr 11 13:09 post-update.sample
-rwxr-xr-x 1 wp_ftp psacln 424 Apr 11 13:09 pre-applypatch.sample
-rwxr-xr-x 1 wp_ftp psacln 1642 Apr 11 13:09 pre-commit.sample
-rwxr-xr-x 1 wp_ftp psacln 1492 Apr 11 13:09 prepare-commit-msg.sample
-rwxr-xr-x 1 wp_ftp psacln 1348 Apr 11 13:09 pre-push.sample
-rwxr-xr-x 1 wp_ftp psacln 4898 Apr 11 13:09 pre-rebase.sample
-rwxr-xr-x 1 wp_ftp psacln 544 Apr 11 13:09 pre-receive.sample
-rwxr-xr-x 1 wp_ftp psacln 3610 Apr 11 13:09 update.sample
but after trying to push something to the Staging system, I've got rejected from the target staging Git
It depends what is the "rejected" message.
If it is
remote: error: refusing to update checked out branch: refs/heads/development
remote: error: By default, updating the current branch in a non-bare repository
That means you need to have a subfolder "bare" within your staging repo:
cd staging
git init --bare . bare
echo /bare/>>.gitignore
git add .gitignore
git commit -m "Ignore nested bare repo /bare/"
git remote add bare bare
git config remote.bare.fetch '+refs/heads/*:refs/remotes/bare/*'
cd bare
git config remote.origin.fetch '+refs/heads/*:refs/remotes/origin/*'
Then modify the bare/hooks/post-receive file in order for it to:
be executable
include the following content
post-receive hook in bare nested bare repository:
#!/bin/bash
unset GIT_DIR
cd ..
git --work-tree=. --git-dir=.git fetch bare
git --work-tree=. --git-dir=.git fetch --tags bare
if ! git --work-tree=. --git-dir=.git merge-base --is-ancestor master origin/master; then
echo "Reset non-bare master to bare master (forced update)"
git --work-tree=. --git-dir=.git reset --hard origin/master
else
echo "Update non-bare master with merge from origin/master"
git --work-tree=. --git-dir=.git pull --no-rebase origin master
fi
Finally, on your dev cloned repo:
cd dev
git config --unset-all remote.origin.pushurl
git config --add remote.origin.pushurl "/path/to/staging/bare"
That way, you are fetching from the Staging repo as usual, but are pushing to the bare nested Staging repo, and the hook will update said Staging content.
How do I cd into a directory and run a script in the same crontab? Currently I'm trying to do something like 32 11 19 1 * cd /Users/myusername/Documents && simple.py but when this runs I receive the error:
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=myusername>
X-Cron-Env: <USER=myusername>
X-Cron-Env: <HOME=/Users/myusername>
Date: Mon, 19 Jan 2015 11:32:00 -0500 (EST)
/bin/sh: simple.py: command not found
How can I fix this?
You must precede with ./ when executing the script from the current working directory.
32 11 19 1 * cd /Users/myusername/Documents && ./simple.py
I guess you script is a python script. /bin/sh: seems weird. If your script is a python script then add following line #!/usr/bin/env python if it does not already contain it.
I am working on Solaris 10 machine. In that i cannot able to untar my file. Logs are given below. Anyone please suggest what may be the issue? I can able to create tar file but unable to untar. :(
bash-3.2# ls -lrth ConfigCheck-120614-KL.out*
-rw-r--r-- 1 root root 144K Jun 12 17:15 ConfigCheck-120614-KL.out
-rwxrwxrwx 1 root root 146K Jun 16 16:49 ConfigCheck-120614-KL.out.tar
bash-3.2# tar xvf ConfigCheck-120614-KL.out.tar
tar: extract not authorized
bash-3.2# tar tvf ConfigCheck-120614-KL.out.tar
-rw-r--r-- 0/0 147377 Jun 12 17:15 2014 ConfigCheck-120614-KL.out
Solaris 11 tar will fail with that error message if you are running as uid 0 but do not have the Media Restore profile set up in the RBAC configuration.
Unless you're trying to restore from backup, you should normally be untarring files as a normal user, not root, to avoid accidentally overwriting critical system files.
my os is debian6,there is a libR.pc after i compile to install R
root#debian:/home/tiger# cat /home/tiger/R-2.15.1/lib/pkgconfig/libR.pc
rhome=/home/tiger/R-2.15.1/lib/R
rlibdir=${rhome}/lib
rincludedir=/home/tiger/R-2.15.1/lib/R/include
Name: libR
Description: R as a library
Version: 2.15.1
Libs: -L${rlibdir} -lR
Cflags: -I${rincludedir} -I${rincludedir}
Libs.private:
when set R environment in /etc/profile:
R_HOME= /home/tiger/R-2.15.1
or
R_HOME= /home/tiger/R-2.15.1/lib/R
which line will i choose to write in /etc/profile?
On a Debian (or derivative such as Ubuntu system) you have /etc/R/ to set variable which R uses:
edd#max:~$ ls -l /etc/R/
total 28
-rw-r--r-- 1 root root 602 Jun 17 20:29 ldpaths
-rw-r--r-- 1 root root 5461 Jun 17 20:29 Makeconf
-rw-r--r-- 1 root root 1868 Mar 31 13:50 Renviron
-rw-r--r-- 1 root root 608 Sep 25 2009 Renviron.site
-rw-r--r-- 1 root root 1159 Mar 31 08:03 repositories
-rw-r--r-- 1 root root 792 Oct 28 2009 Rprofile.site
edd#max:~$
and the files in R_HOME/etc/ should be softlinks --- at least if you use the prebuilt binaries. If you build you own binaries, it's your problem.
The file you quote is installed as /usr/lib/pkgconfig/libR.pc on a Debian / Ubuntu system. Setting R_HOME is not needed as R finds its own values (see #flodel's answer).
On my system:
cat $R_HOME
gives nothing, but inside an R session, I get:
> Sys.getenv("R_HOME")
[1] "/usr/lib/R"
This should tell you two things:
that R_HOME is set at R's startup, so unless you know exactly what you are doing, maybe you don't need to set it up in your /etc/profile.
you can use Sys.getenv to find out the exact path to your R_HOME.