Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help compile a script file 1

Status
Not open for further replies.

Dirtbike

IS-IT--Management
Dec 9, 2002
81
US
You guys have help me build this little script that starts with while. It works great to loop my if statement. My request is a way to convert this puppy into something that will run without using a tty. You know, run as a stand alone deamon. Thanks for helping this old UNIX newbie..

Scott in Charlotte, NC
 
Can you post the script you want to daemonize ?
 
Here is the code I want to deamonize:

while true
do
if [ -e "/sw7/SHIP/SHIP/ICV/ICVER12 .REQ" ] ; then
mv "/sw7/SHIP/SHIP/ICV/ICVER12 .REQ" /sw7/SHIP/SHIP/ICVDATA/icver012.req
fi
if [ -e /sw7/SHIP/SHIP/ICVDATA/icver012.ans ] ; then
mv "/sw7/SHIP/SHIP/ICVDATA/icver012.ans "/sw7/SHIP/SHIP/ICV/ICVER12 .REQ"
fi
sleep 5
done

Actually this is only part 12 of 12. I will need 11 more iterations counting from 12 down to 1.
Any help would be greatly appreciated!!
 
Something like this ?
Code:
#!/bin/ksh
typeset -L3 l; typeset -Z3 z
ICV="/sw7/SHIP/SHIP/ICV"
ICVDATA="/sw7/SHIP/SHIP/ICVDATA"
while true; do
  for i in 12 11 10 9 8 7 6 5 4 3 2 1; do
    l=i; z=i
    [ -e "$ICV/ICVER$l.REQ" ] &&
      mv "$ICV/ICVER$l.REQ" $ICVDATA/icver$z.req
    [ -e $ICVDATA/icver$z.ans ] &&
      mv $ICVDATA/icver$2.ans "$ICV/ICVER$l.REQ"
  done
  sleep 5
done

Hope This Help
PH.
 
stanhubble, arent't the spaces preserved with this ?
Code:
typeset -L3 l
 
Stan and PV--
Thanks for all your help!! I'm sure this next concern is a "no-brainer" for you guys.....but...it doesn't work. I get a fix[2]: typeset: -- illegal option error. Whazzup with that? I tried to get help with the typeset command with no luck. I REALLY appreciate the help you guys have afforded me to date. Have a great Tuesday!

Scott in Charlotte, NC
 
OK, My bad :(
I edited your code and accused you of writing bad code....my bad...many appologies. Here is why I changed your code. If the file I need to change name/dir is ICVER12 .REQ than it changes to icver012.req. If the file is ICVER1 .REQ it needs to change to icver001.req. You see where the 2 digit number needs a preceeding 0 and the 1 digit number needs a preceeding 00. So I thought.....well let's not get into my bass-ackward thought process...here is what I thought would work..

#!/bin/ksh
typeset -L3 l; typeset -Z3 z; typeset -X3 x; typeset -Y3 y
ICV="/sw7/SHIP/SHIP/ICV"
ICVDATA="/sw7/SHIP/SHIP/ICVDATA"
while true; do
for i in 12 11 10; do
l=i; z=i
[ -e "$ICV/ICVER$l .REQ" ] &&
mv "$ICV/ICVER$l .REQ" $ICVDATA/icver0$z.req
[ -e $ICVDATA/icver0$z.ans ] &&
mv $ICVDATA/icver0$z.ans "$ICV/ICVER$l .ANS”
done
for i in 9 8 7 6 5 4 3 2 1; do
x=i; y=i
[ -e "$ICV/ICVER$x .REQ" ] &&
mv "$ICV/ICVER$x .REQ" $ICVDATA/icver00$y.req
[ -e $ICVDATA/icver00$y.ans ] &&
mv $ICVDATA/icver00$y.ans "$ICV/ICVER$x .ANS"
done
sleep 5
done

Am I even close? Thasnks again for all your help here!

Scott in Charlotte, NC
 
PHV, yeah it is preserved....
I never use ksh in examples and very rarely on our own systems so i didn't pay much attention to that line...;)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top