Sponsored Content
Top Forums Shell Programming and Scripting Create Jar using shell script Post 302357050 by johnycage on Monday 28th of September 2009 02:05:40 PM
Old 09-28-2009
Create Jar using shell script

Hi Folks

I came up with peculiar requierement ..Smilie

I have to jar special files types only from a number of child folders , and also exactly same as the child file path...sorry i will give an example

suppose i have following folder structure

# cd HTML/
total 0
drwxrwxr-x 2 johycage johycage 96 Sep 23 07:42 HTML
drwxrwxr-x 2 johycage johycage 96 Sep 23 07:42 XML
-rw-rw-r-- 1 johycage johycage 0 Sep 23 07:42 1.html
-rw-rw-r-- 1 johycage johycage 0 Sep 23 07:42 2.html
#cd HTML/
total 0
-rw-rw-r-- 1 johycage johycage 0 Sep 23 07:42 1.html
-rw-rw-r-- 1 johycage johycage 0 Sep 23 07:42 2.html
# cd ../XML/
total 0
-rw-rw-r-- 1 johycage johycage 0 Sep 23 07:42 1.xml
-rw-rw-r-- 1 johycage johycage 0 Sep 23 07:42 2.xml

And all i want is to create jar file which contain onlt html file types in the following manner.

# jar -tvf test.jar
0 Wed Sep 23 07:42:22 MST 2009 home/johycage/HTML/HTML/1.html
0 Wed Sep 23 07:42:28 MST 2009 home/johycage/HTML/HTML/2.html
0 Wed Sep 23 07:42:50 MST 2009 home/johycage/HTML/1.html
0 Wed Sep 23 07:42:56 MST 2009 home/johycage/HTML/2.html

I have achieved this using below simple scriipt. But as you know adding files using jar -uvf take much time if folder strcture is more complex. I am attaching the script below which used, Anyone have a better idea ???

touch test.jar
find /home/johnycage/HTML/ -name '*.html' -print| while read obj
do
jar -uvf test.jar $obj
done

cheers Smilie
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

create a shell script

create a shell script that process a file file contain f2f_100.txt 1234 kkk 12345 f2f_101.txt 1234 mmm 11111 retire_200.txt 2222 rrr 22222 retire_201.txt 1112 qqr 12122 output needed if first field is f2f then new file fb_$1 contain $2|$4 ... (3 Replies)
Discussion started by: maykap100
3 Replies

2. Shell Programming and Scripting

create a shell script that calls another script and and an awk script

Hi guys I have a shell script that executes sql statemets and sends the output to a file.the script takes in parameters executes sql and sends the result to an output file. #!/bin/sh echo " $2 $3 $4 $5 $6 $7 isql -w400 -U$2 -S$5 -P$3 << xxx use $4 go print"**Changes to the table... (0 Replies)
Discussion started by: magikminox
0 Replies

3. UNIX for Dummies Questions & Answers

How to create a service from a jar file.

Hi, I am new to Linux. I have a executable jar file which I need to run even before the user logs in. The problem is since I don't have good information about the services in Linux its very difficult to understand the same topic posted at other forums. I have tried many things like java... (0 Replies)
Discussion started by: ankushpandit
0 Replies

4. Shell Programming and Scripting

Need help to create shell script.

When i run the following command it shows me following o/p # prtpicl -v -c temperature-sensor | sed -n '/T_TCORE/,/:name/ p' | grep Temperature 61 Temperature 62 i want to put this command in shell script so that when i run the script it says ********************* Proc1 ... (4 Replies)
Discussion started by: fugitive
4 Replies

5. Shell Programming and Scripting

To Create shell script files from a shell script

Dear Unix and Linux users, Good evening to all. I'm new to this community and thank you for having an wonderful forum. Dear members i had to create almost some 300 shell script files for a particular task. I tried something like this.... #!usr/bin/sh fname=epdb_jobs for x in `cat $fname`... (3 Replies)
Discussion started by: NehaB
3 Replies

6. Shell Programming and Scripting

Create Shell Script

Create a script to do the following : a. Poll for ctl file abc.ctl b. if the ctl file is found, then check for corresponding dat file(abc.dat) c. if dat file is not found then fail the process e. if dat file is found do file validation File Validation: a. Check the... (1 Reply)
Discussion started by: vivek1489
1 Replies

7. Shell Programming and Scripting

Create file from script shell

Hello all :) Here is my code i try to complete: address1="$(ssh root@$machine -x "lxc-info -n $machine-worker1 -H -i")" if //ifthe file addrfile does not exist then create the file addrfile echo "$address1">"$addrfile" fi "$address1">"$addrfile" How, can i... (4 Replies)
Discussion started by: chercheur111
4 Replies

8. Shell Programming and Scripting

Shell script to encrypt the xls file using executable jar in Linux SUSE 11.4

Dear Experts, I am an ERP consultant and would like to learn shell script. We are working on Linux SUSE 11.4 and I am very new to shell scripting. We can manually encrypt an excel file using "executable jar" through command prompt by placing the jar file & the file to be encrypted on a physical... (1 Reply)
Discussion started by: nithin226
1 Replies

9. Shell Programming and Scripting

Shell script to create runtime variables based on the number of parameters passed in the script

Hi All, I have a script which intends to create as many variables at runtime, as the number of parameters passed to it. The script needs to save these parameter values in the variables created and print them abc.sh ---------- export Numbr_Parms=$# export a=1 while do export... (3 Replies)
Discussion started by: dev.devil.1983
3 Replies
FORK(2) 							System Calls Manual							   FORK(2)

NAME
fork - create a new process SYNOPSIS
#include <sys/types.h> #include <unistd.h> pid_t fork(void) DESCRIPTION
Fork causes creation of a new process. The new process (child process) is an exact copy of the calling process except for the following: The child process has a unique process ID. The child process has a different parent process ID (i.e., the process ID of the parent process). The child process has its own copy of the parent's descriptors. These descriptors reference the same underlying objects, so that, for instance, file pointers in file objects are shared between the child and the parent, so that an lseek(2) on a descriptor in the child process can affect a subsequent read or write by the parent. This descriptor copying is also used by the shell to establish standard input and output for newly created processes as well as to set up pipes. The child starts with no pending signals and an inactive alarm timer. RETURN VALUE
Upon successful completion, fork returns a value of 0 to the child process and returns the process ID of the child process to the parent process. Otherwise, a value of -1 is returned to the parent process, no child process is created, and the global variable errno is set to indicate the error. ERRORS
Fork will fail and no child process will be created if one or more of the following are true: [EAGAIN] The system-imposed limit on the total number of processes under execution would be exceeded. This limit is configuration- dependent. (The kernel variable NR_PROCS in <minix/config.h> (Minix), or <minix/const.h> (Minix-vmd).) [ENOMEM] There is insufficient (virtual) memory for the new process. SEE ALSO
execve(2), wait(2). 3rd Berkeley Distribution May 22, 1986 FORK(2)
All times are GMT -4. The time now is 02:56 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy