Mourning the loss of our friend, WhitPhil.
There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
Search
 
Linux and Unix
Tag Cloud
access audio black screen blue screen boot bsod connection crash dell desktop driver dvd email error excel excel 2003 firefox hard drive hardware hijackthis internet keyboard laptop malware monitor network networking outlook problem processor ram recovery router safe mode screen slow sound spyware tdlwsp.dll trojan vba video virus vista vundo windows windows 7 windows vista windows xp wireless
Search
Search for:
Tech Support Guy Forums > Operating Systems > Linux and Unix >
more on shells scripting

Tip: Click here to scan for System Errors and Optimize PC performance
[ Sponsored Link ]

Closed Thread
 
Thread Tools
soup4you2's Avatar
Member with 71 posts.
 
Join Date: Jul 2003
21-Oct-2003, 12:47 PM #1
more on shells scripting
Ok for some reason this script is not working.. and i was hoping somebody could point out my error.. if i run

root1=`roots="ls -d $CHROOTS/*/" | echo $roots | awk '{ print $3 }'` ; echo $root1

it works from the cmd line.. but not inside the script.. $root1-7 are not being passed..

Code:
function sec_4 {
root1=`roots="ls -d $CHROOTS/*/" | echo $roots | awk '{ print $3 }'`
root2=`roots="ls -d $CHROOTS/*/" | echo $roots | awk '{ print $4 }'`
root3=`roots="ls -d $CHROOTS/*/" | echo $roots | awk '{ print $5 }'`
root4=`roots="ls -d $CHROOTS/*/" | echo $roots | awk '{ print $6 }'`
root5=`roots="ls -d $CHROOTS/*/" | echo $roots | awk '{ print $7 }'`
root6=`roots="ls -d $CHROOTS/*/" | echo $roots | awk '{ print $8 }'`
root7=`roots="ls -d $CHROOTS/*/" | echo $roots | awk '{ print $9 }'`


if [ "$root1" = "" ]; then
sec_4_done
fi
cd /$CHROOTS/$root1
 for file in `find usr/ -type f `; do
  if [ /$file -nt $file ]; then
    cp -v /$file $file
  fi
done 
if [ "$root2" = "" ]; then
sec_4_done
fi
cd /$CHROOTS/$root2
 for file in `find usr/ -type f `; do
  if [ /$file -nt $file ]; then
    cp -v /$file $file
  fi
done 
if [ "$root3" = "" ]; then
sec_4_done
fi
cd /$CHROOTS/$root3
 for file in `find usr/ -type f `; do
  if [ /$file -nt $file ]; then
    cp -v /$file $file
  fi
done 
if [ "$root4" = "" ]; then
sec_4_done
fi
cd /$CHROOTS/$root4
 for file in `find usr/ -type f `; do
  if [ /$file -nt $file ]; then
    cp -v /$file $file
  fi
done 
if [ "$root5" = "" ]; then
sec_4_done
fi
cd /$CHROOTS/$root5
 for file in `find usr/ -type f `; do
  if [ /$file -nt $file ]; then
    cp -v /$file $file
  fi
done 
if [ "$root6" = "" ]; then
sec_4_done
fi
cd /$CHROOTS/$root6
 for file in `find usr/ -type f `; do
  if [ /$file -nt $file ]; then
    cp -v /$file $file
  fi
done 
if [ "$root7" = "" ]; then
sec_4_done
fi
cd /$CHROOTS/$root7
 for file in `find usr/ -type f `; do
  if [ /$file -nt $file ]; then
    cp -v /$file $file
  fi
done 
sec_done
}
__________________
Soup's Website
soup4you2's Avatar
Member with 71 posts.
 
Join Date: Jul 2003
21-Oct-2003, 06:07 PM #2
resolved..

roots="ls -d $CHROOTS/*/"
root1=$(echo $roots | awk '{ print $3 }')
lynch's Avatar
Senior Member with 1,962 posts.
 
Join Date: Aug 2002
Location: Back East,Way Back East
24-Oct-2003, 05:38 AM #3
Hey,soup4you2.
Just curious;what's this script do?
lynch
codejockey's Avatar
Senior Member with 1,410 posts.
 
Join Date: Feb 2002
29-Oct-2003, 05:04 PM #4
Just a quick note: I believe echo does not read from stdin; attempting to pipe to echo produces undefined results (e.g., on many BSD-based systems, it used to reset your pgroup!). Note that the revised script avoids this problem.

I believe the intent of the script is to locate a directory tree below $CHROOTS (previously defined), and compare contents with those in the /usr directory. If the $CHROOTS-based file is newer than the root version, the $CHROOTS-based file is copied to root. The script might be, for example, a way to update a new installation of Linux with customized files from a previous installation.

Just my $0.02 within $0.05 rounding error ... ()
__________________
The slowest component still sits at the keyboard.
lynch's Avatar
Senior Member with 1,962 posts.
 
Join Date: Aug 2002
Location: Back East,Way Back East
29-Oct-2003, 05:18 PM #5
Thanks for the answer,codejockey.(I forgot I asked )
lynch
codejockey's Avatar
Senior Member with 1,410 posts.
 
Join Date: Feb 2002
29-Oct-2003, 05:37 PM #6
Well, it may be an answer, but it doesn't mean it's right () ... I figure soup4you2 can enlighten us both ...
Closed Thread Bookmark and Share

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Smart Search

Find your solution!



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.

Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -5. The time now is 12:27 PM.
Copyright © 1996 - 2009 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.
Powered by Cermak Technologies, Inc.