Spot the difference


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Spot the difference
# 1  
Old 07-31-2006
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
# 2  
Old 07-31-2006
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  
Old 07-31-2006
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  
Old 07-31-2006
define "good" - it looks like you are writing a scripted front-end for shar....
# 5  
Old 07-31-2006
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  
Old 07-31-2006
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.
# 7  
Old 08-02-2006
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
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. AIX

Unable to create a SPOT

Hi everyone! Ok so I'm trying for the first time to install AIX on a LPAR with NIM. The NIM: root@oaexpnimp01(/home/root) # oslevel -s 6100-08-02-1316 I'm trying to install AIX 6.1 TL1. I successfully created a new lpp source root@oaexpnimp01(/home/root) # lsnim -l AIX61_TL1_2... (10 Replies)
Discussion started by: trivium012
10 Replies

2. UNIX for Dummies Questions & Answers

Can anyone help me to spot my mistake?

Hi there can anyone help me to spot my mistake and please explain why it appears My code : #!/usr/bin/gawk -f BEGIN { bytes =0} { temp=$(grep "datafeed\.php" | cut -d" " -f8) bytes += temp} END { printf "Number of bytes: %d\n", bytes } when I am running ./q411 an411 an411: ... (6 Replies)
Discussion started by: FUTURE_EINSTEIN
6 Replies

3. AIX

NIM SPOT query

Dear Admins, The SPOT defined in NIM is for aix 5.3 TL 7 . Some of the NIM clients are upgraded to TL 10 . Now the SPOT level is older than the mksysb level. This will cause problem during restoration of any NIM clients. Now i want to upgrade SPOT level to TL 10 and redefine the resources... (3 Replies)
Discussion started by: newaix
3 Replies

4. AIX

how to make a spot

HI. there My 10 servers are running on 6.1-05-03 aix including NIM server but my user want to update a TL (61-05-03 to 61-06-04) if I Update a AIx version of TL .. is that change the SPOT of NIM server.. OR if I make a spot of AIX7.1 and Is that support AIX 6.1 AIX 5.3 Images I... (1 Reply)
Discussion started by: Jeon Jun Seok
1 Replies

5. Shell Programming and Scripting

How do I search with regex in one spot?

Hello im new here and i shot stright with question. Mainly i wanna ask , how do i search with regexp in one spot and show the whole thing, what im trying to ask is , for eg. i do ls -l, and i see all the info for the dirs and dats. now say i wanna get all the dats that in their name they start... (2 Replies)
Discussion started by: Goroner
2 Replies

6. AIX

SPOT requirement

Hey May be a dumb question Can I use a SPOT which is at 5.3 TL6 to boot an LPAR (with 5.3 TL8) in to maintenance mode? Will it work ? Is it mandatory that SPOT should be of same or higher version in such case? Bala (1 Reply)
Discussion started by: balaji_prk
1 Replies

7. UNIX for Advanced & Expert Users

Spot

does somebody know about SPOT ?? any link about SPOT commands ? i ve made a mistake during configuration, :mad: then i ve started the system in Maintenance mode the only shell was SPOT. :eek: SPOT doesn t understand anything.... how do i work with SPOT ? thanks in advance Karine... :D (1 Reply)
Discussion started by: karine
1 Replies
Login or Register to Ask a Question