![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
| How to cut a text file at a certain spot? | LordJezo | Shell Programming and Scripting | 2 | 11-12-2008 12:10 PM |
| Bringing your photos from F-Spot to the Web | iBot | UNIX and Linux RSS News | 0 | 05-02-2008 12:50 PM |
| Logrotate problems - Can anyone spot the problem please?! | anderow | UNIX for Dummies Questions & Answers | 10 | 01-10-2008 08:56 PM |
| Add a line to a specific spot in a file | d__browne | UNIX for Advanced & Expert Users | 6 | 12-07-2006 07:52 AM |
| Spot | karine | UNIX for Advanced & Expert Users | 1 | 02-08-2005 05:18 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Spot the difference
I posted earlier with a problem it's here, I have edited the script a little and it tells me once more that the end of line is unexpected and I'm really lost with this one, thanks for any help.
The new version: #!/bin/sh case $# in 0) echo "Usage: enshar filename1 filename2 [...]" >&2 ;; *) for file do if [ -d $file ] then echo "enshar: $file is a directory" >&2 elif [ ! -f $file ] then echo "enshar: $file does not exist" >&2 elif [ ! -r $file ] then echo "enshar: $file is not readable" >&2 elif [ -h $file ] then echo "enshar: $file cannot enshar" >&2 exit n else echo "\!EnShAr!\" set '"cksum" $file' "test $1 = nnnnnnnnnn || echo $0: bad cksum in $file << '\!EnShAr!\'" cat $file fi done ;; esac |
|
||||
|
Use code tags!! Code:
#!/bin/sh
if [ $# -eq 0 ] ; then
echo "Usage: enshar filename1 filename2 [...]" >&2
exit 1
fi
for file in "$@"
do
if [ -d $file ]
then
echo "enshar: $file is a directory" >2
exit 1
elif [ ! -f $file ]
then
echo "enshar: $file does not exist" >2
exit 1
elif [ ! -r $file ]
then
echo "enshar: $file is not readable" >2
exit 1
elif [ -h $file ]
then
echo "enshar: $file cannot enshar" >2
exit 1
fi
cksum $file| read ck summy1 dummy2 # ck is the checksum
echo "\!EnShAr!\ "
# no idea what this line is doing. $1 cannot be used here and << makes no sense to me
# try writing this out, not as script, but as what you want done here...
"test $file = nnnnnnnnnn || echo $0: bad cksum in $file << '\!EnShAr!\'"
cat $file
done
|
|
||||
|
okay, i'm checking that the file is enshared correctly , that theres no proplems that have happened during it being not archived and then it being, not quite sure of the method you see, just been playing around with it but I have not got it to work correctly yet so wondered if there was someone who knew more about it then me, again thnks for any help offered
|
|
|||||
|
I can shed some light here. Look at your earlier code: Code:
echo "cat > $file <<\!EnShAr!"
cat $file
echo "!EnShAr!"
echo "set `cksum $file`"
echo "cksum" $file`
check=$1
echo "test $1 = $check || echo $0: Bad cksum in $file >&2 " >> shar
echo "cat > $file <<\!EnShAr!" >> shar
This code is outputting another shell script. One shell script is writing a second shell script. The first 3 lines will output: cat > /some/file/name <<!EnShAr! contents of /some/file/name !EnShAr! In this context, that line: echo "!EnShAr!" makes perfect sense. You stripped out enough code that it is now useless. Put the script back the way it was. It was useful then. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|