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 acer asus bios bsod computer crash drive driver drivers error ethernet excel freeze games gaming hard drive hardware hdmi internet java laptop malware memory monitor motherboard music network obp printer problem ram random registry router slow software sound trojan usb video virus vista wifi windows windows 7 windows 7 32 bit windows 7 64 bit windows xp wireless
Search
Search for:
Tech Support Guy Forums > Operating Systems > Linux and Unix >
more on shells scripting

Reply  
Thread Tools
soup4you2's Avatar
Member with 71 posts.
 
Join Date: Jul 2003
21-Oct-2003, 01: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, 07: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, 06: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, 06: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, 06: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, 06:37 PM #6
Well, it may be an answer, but it doesn't mean it's right () ... I figure soup4you2 can enlighten us both ...
Reply

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.

Search Tech Support Guy

Find the solution to your
computer problem!




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



Facebook Facebook Twitter Twitter TechGuy.tv TechGuy.tv Mobile TSG Mobile
You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 07:17 AM.
Copyright © 1996 - 2011 TechGuy, Inc. All rights reserved.

Powered by Cermak Technologies, Inc.