Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Bash / Shell Scripting (http://www.programmingforums.org/forum26.html)
-   -   scripting question (http://www.programmingforums.org/showthread.php?t=15095)

sons_of_bitch Jan 31st, 2008 12:52 AM

scripting question
 
hi all,

i'm new here, i would like to add on the print command to prompt user to enter a value and store inside the variable name as $inName like
print "what is your directory : ";
then the answer is storing to &inName

after that the value will replace the existing line for ${METRICA_DIR}/TechnologyPacks/Spool/2030324032
i'm new in scripting, could anyone give me some hint for sripting?

tmpfile=/tmp/tmpfile.$$

for file in loaderconfiguration*.xml
do
sed "s|${METRICA_DIR}/TechnologyPacks/Spool/2030324032|$inName|g" $file > $tmpfile
mv $tmpfile $file
done

thanks

jim mcnamara Feb 11th, 2008 2:24 PM

Re: scripting question
 
:

echo "Which directory \c"
read directory
tmpfile=/tmp/tmpfile.$$

for file in loaderconfiguration*.xml
do
  sed "s|${directory}|$inName|g" $file > $tmpfile
  mv $tmpfile $file
done


BEFORE you run this - where is the variable inName defined in your code? As is, it is null.
It needs to be set to something, somewhere, before the for loop.


All times are GMT -5. The time now is 12:29 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC