Spot the difference


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Spot the difference
# 15  
Old 08-03-2006
instead of escaping ! , u have escaped " at line
echo "\!EnShAr!\"

change it to
echo "\!EnShAr\!"

Regards,
------------
Suman
# 16  
Old 08-03-2006
okay my script for the shar section looks like this at the mo:

if
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 " >> sharS
echo "cat > $file <<\!EnShAr!" >> sharS
fi

-----------------------------------------------------------------------------------
If I do as told to do buy the last post:
"echo "cat > $file <<\!EnShAr\!"
Then it crashes at the fi not being expected,

if I don't it still crashes saying that the end of line is not expected at the end,

Any advice somebody?
# 17  
Old 08-03-2006
Now you've done it...
Image

Code:
if
then
  echo "cat > $file <<\!EnShAr\!"
  echo "\!EnShAr\!"
  echo "set `cksum $file`"
# Needed a space between echo and "cksum"
  echo "cksum" $file
# Is this supposed to be echoed?
  check=$1
  echo "test $1 = $check || echo $0: bad cksum in $file >&2 " >> sharS
  echo "cat > $file <<\!EnShAr\!" >> sharS
fi

Got to watch those exclamation marks. They mean something special in sh, even inside double quotes. Maybye make that !EnShAr! thing a variable so you don't have to type the various crazy escapings every time?
# 18  
Old 08-03-2006
There is nothing wrong with this:
Code:
#! /usr/bin/ksh

for par ; do
        echo par = $par
done
exit 0

And that will work fine with the Bourne shell too. When a for statement does not have an explicit list, it will step through the positional parameters. Call that little script "fortest" and and it with:
./fortest one two three
It will work fine.

Next, shells have special characters like " and $ that mean special things. Generally a backshash will remove the special meaning from a special character. Now look at this line:
echo "cat > $file <<\!EnShAr!\"
You have removed the special meaning from the last quote so it does not match up with the first quote. So the shell reads the next line and find a normal quote there that ends the quoted string. Your quoted string contains a quote and it goes into a second line which is legal. Now everything is mexed up and the shell will finally barf on the last quote.
# 19  
Old 08-03-2006
Have you tried running it on unix? it does not seem to work on mine, if you can show me a version you know works and I'll see if I'm the one with unix being difficult, thanks
# 20  
Old 08-04-2006
i don't mean the whole thing by the way, just this shar section, i don't wanna have to rewrite the script to use differnt functions. Thanks for any help given
# 21  
Old 08-04-2006
Hi, this is a cut down version that I have written from scratch to try and solve the problems I'm having:


#!/bin/sh
filevalidate()
{
case $# in
0) echo "Usage enshar file1 file2 ... > outputFile ! " > /bin/sharF/error ;;

*) for filename
do

if [ -d $filename ]; then
echo "invalid path name " > $filename > /bin/sharF/error
exit 2
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 > /bin/sharF/error"
done

exit 0

Does anyone see any issues? I could not get it to work so I took the end section from:

for filename in $*
do
echo cat \> $filename \<\<"\\!EnShAr\!"

and tried to run it alone, but an error occurs on line 7 to do with "`
Can someone check my ` ' " please and my redirection stuff, and if the cksum looks like that should work because I have been unable to test it.
Can someone please assist!!!
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