The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Find duplicates from multuple files with 2 diff types of files ricky007 Shell Programming and Scripting 2 03-04-2008 01:46 PM
unzip particular gzip files among the normal data files thepurple Shell Programming and Scripting 4 11-30-2007 11:17 AM
installation of many patches / bundle vipsinghal HP-UX 2 11-08-2006 06:00 PM
when I try to run rm on multiple files I have problem to delete files with space umen UNIX for Dummies Questions & Answers 1 09-20-2005 04:20 AM
text files, ASCII files, binary files and ftp transfers Perderabo Answers to Frequently Asked Questions 0 04-08-2004 05:25 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-27-2006
swissnez swissnez is offline
Registered User
  
 

Join Date: Apr 2006
Posts: 3
Wink please can any one help me bundle several files into one

#!/bin/sh
#call function from loop
filevalidate()
{
case $# in
0) echo "usage enshar file1 file2 ... > outputfile ! " >/deb/sterr ;;
*) for filename
do

if [ $filename -gt 1 ]; then
echo "invalid pathname > try bin " $filename >/dev/stderr
exit 1
fi

if [ -d $filename ]; then
echo "is a directory!" $filename >/dev/stderr
exit 2
fi

if [ ! -r $filename ] || [ ! -f $filename ]; then
echo "unreadable or non existant " $filename >/dev/stderr
exit 3
fi

grep -- "^!EnShAr!" "$filename"

if [ $? -eq 0 ]; then
echo "cant enshar it or already enshared! " $filename >/dev/stderr
exit 5
fi
if [ $filename = "" ]; then
echo "usage is enshar file1 file2 .. > outputfile" >/dev/stderr
exit 6
fi

done ;;
esac
}


for filename in $*
do
filevalidate $filename
done

for filename in $*
do
echo cat \>$filename \<\<"\\!EnShAr!"
cat <$filename
echo "!EnShAr!"
echo set \`cksum $filename\`
set `cksum $filename`
echo "test \$filename = $filename || echo \$0: BAD checksum in
$filename >&2"
done

exit 0



#this is what i have so far and only works 80%
#kind regards
  #2 (permalink)  
Old 04-27-2006
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,762
Is there a reason you cannot use tar?
If you tell us exactly what you are trying to do, we can help you.
  #3 (permalink)  
Old 04-27-2006
swissnez swissnez is offline
Registered User
  
 

Join Date: Apr 2006
Posts: 3
thats the point no compression utiliy as it use CPU usuage

thats the point no compression utiliy as it use CPU usuage

any thanks for responding !!
  #4 (permalink)  
Old 04-27-2006
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,762
um, what you're doing has cpu usage. tar does what shar does, it packs, it doesn't necessarily compress or encrypt files. You can read a tar in an editor.
Especially if it's just a text file archive. Anyway, how you pack things is not that important.

Again, can you tell us what you are trying to do, minus the cpu problem.

In other words, what are your requirements?

Last edited by jim mcnamara; 04-27-2006 at 02:23 PM..
  #5 (permalink)  
Old 04-27-2006
swissnez swissnez is offline
Registered User
  
 

Join Date: Apr 2006
Posts: 3
Red face To be honest the CPU is irrelavant but its a demonstatration script

$ enshar README cars Unix > eg.shar
$ mailx -s 'Re: Please send me your brilliant stuff' \
> p.scott@shu.ac.uk < eg.shar
$

You have to:

o work out how to use the shar file to extract the files it
contains,

o work out how it works, and

o write a shell script called `enshar' to produce shar files to
exactly the same format. (But your's won't have been e-mailed, so
they won't have any e-mail headers!)

Notice that `enshar' doesn't generate files directly; it only sends to
standard output. In the example, `eg.shar' was created because the
user redirected `enshar's output into `eg.shar'.


If `enshar' finds an error, it outputs an error message and executes an
`exit n'. The required error messages and the values of `n' are as
follows:

1 Usage: enshar file [ ... ]

2 enshar: <parameter>: can't be a pathname

3 enshar: <parameter>: is a directory

4 enshar: <parameter>: doesn't exist

5 enshar: <parameter>: can't be read

6 enshar: <parameter>: can't enshar

Notes:

o The first error message is given if the script is called without
parameters.

o The second error message is given if a parameter has a `/' character
in it.

o Error messages three to five are given if the file specified by a
parameter is: a directory, non-existant or unreadable.

o Error message six is given if the file specified by the parameter
contains the line that is used as the `here document' delimiter.

o `enshar' doesn't need to check all its parameters before generating
any output. That is, it can fail after outputting part of the shar
file. It would be an error for `enshar' to output anything else after
generating an error message.

6 In error messages two to six `<parameter>' should be replaced by the
value of the actual parameter that caused the problem.
  #6 (permalink)  
Old 04-27-2006
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,762
Homework. You should read the FAQ. Homework help is not allowed here.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:31 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0