![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
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 |
| for loop sytax error | Rajat | UNIX for Dummies Questions & Answers | 3 | 07-02-2008 10:39 AM |
| syntax error in while loop | habzone2007 | Shell Programming and Scripting | 1 | 05-18-2008 04:31 PM |
| Stange problem Dell PowerEdge 1950/ Boradcom Netextreme NIC | skotapal | UNIX for Dummies Questions & Answers | 0 | 10-17-2007 02:50 PM |
| Unix-Sql Loop error | manu_byc | Shell Programming and Scripting | 3 | 02-05-2007 09:40 AM |
| Error in for loop? | hugow | UNIX for Dummies Questions & Answers | 3 | 06-28-2005 03:03 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
While Loop - stange error
Hello
I am writing a script to copy files that contains a while loop to compare files that will do a cp -p until the filesizes are equal. I am getting a strange error though when the script gets to executing the while loop. here is my code: Code:
#/usr/bin/csh
#create the filename
echo "What is the name of the file you want created?"
set filename =<
touch $filename
#for some reason i had to touch the file 2 times to create it
touch $filename
#echo the filesize to make sure its 0 and that it was created
ls -l $filename | awk '{print $5}'
#ask the user what file they want copied
echo "what file do you want copied?"
set filecopy =<
#ensure the filesize to be copied named as filecopy
ls -l $filecopy | awk '{print $5}'
while ["$filename" ne "filecopy"]
do cp -p $filecopy $filename
until "$filename" = "$filecopy"
endwhile
#do some math to give the user some sort of idea how far along we are
#to be implemented later
end
i have tried several different whiles, like this [while foo do something] and [[while foo do something ]] and quotes, no quotes around the variables as well as tick marks... so here are my questions: 1. if i just used a file to compare against, is it possible that the while operation is messing up there? 2. i used the solaris scripting book and it said two brackets and quotes. whatever assistance you can provide would be greatly appreciated. Thanks!! Joe |
|
||||
|
Thanks, i found another error so i will re write it in the korn shell. I was also wanting to change it so that i am putting the cp -p in the background and performing some math operations to let the user know that their copy is still in progress.
and yes, it was not a direct copy and paste, so the errors that you all found were definitely errors. Thanks for your inputs again! Happy scripting |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|