![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | 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 here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to cut a text file at a certain spot? | LordJezo | Shell Programming and Scripting | 2 | 2 Weeks Ago 09:10 AM |
| Bringing your photos from F-Spot to the Web | iBot | UNIX and Linux RSS News | 0 | 05-02-2008 08:50 AM |
| Logrotate problems - Can anyone spot the problem please?! | anderow | UNIX for Dummies Questions & Answers | 10 | 01-10-2008 05:56 PM |
| Add a line to a specific spot in a file | d__browne | UNIX for Advanced & Expert Users | 6 | 12-07-2006 04:52 AM |
| Spot | karine | UNIX for Advanced & Expert Users | 1 | 02-08-2005 02:18 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
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
|
|
#3
|
|||
|
|||
|
Hi, I am trying to check the file is good, can you show me how this section would be done properly but I want the same format output as originally stated, thanks for any help
|
|
#4
|
|||
|
|||
|
define "good" - it looks like you are writing a scripted front-end for shar....
|
|
#5
|
|||
|
|||
|
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
|
|
#6
|
||||
|
||||
|
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
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. |
|
#7
|
|||
|
|||
|
Hi, thanks for your help earlier, to my understanding this code looks like it should work and I'm very excited about it but the damn thing says the end of line 27 is unexpected, please help!
#!/bin/sh case $# in 0) echo "Usage: enshar file [ ... ]" >&2 exit 1 ;; *) for file do if [ -d $file ] then echo "enshar: $file is a directory" >&2 exit 3 elif [ ! -f $file ] then echo "enshar: $file doesn't exist" >&2 exit 4 elif [ ! -r $file ] then echo "enshar: $file can't be read" >&2 exit 5 elif [ -h $file ] then echo "enshar: $file can't enshar" >&2 exit 6 else echo "cat > $file <<\!EnShAr!\" 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 fi done ;; esac p.s, where should the "fi" be, thanks for any help |
|||
| Google The UNIX and Linux Forums |