While loop not working


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting While loop not working
# 1  
Old 06-15-2010
While loop not working

here we go..

While loop is not working file.. It also invokes one more shell scripts for which parameters need to passed on.
Code:
while read line
do
        ####
        ####  We want to have a logfile for each load
        ####
        PLog="${LogDir}/${Script}.log";
        ####
        ####  Need to keep creating DDL one after another
        ####
        echo "${line}" >> ${ProFILE}
        ${line} >>  ${PLog}
done < ${INPUT_FILE}

INPUT_FILE
Code:
 
ksh invoke.ksh <parameter1> <parameter2>

Moderator's Comments:
Mod Comment Use code tags please, ty.

Last edited by zaxxon; 06-15-2010 at 01:28 AM.. Reason: code tags
# 2  
Old 06-15-2010
Quote:
#### We want to have a logfile for each load
Then maybe build in a counter ie. a variable that is set in the start to 1 and at the end of the loop (still inside) is incremented by 1, using the shell's arithmetic functions or let or expr. Use this variable in the filename when redirecting output so you have different names for each load counting up.

Code:
ksh invoke.ksh <parameter1> <parameter2>

The ksh is not needed in front of the line. Remove it and use a sheband which means 1st line in your script has to be
Code:
#!/usr/bin/ksh

<parameter1> will be $1 inside your script and <parameter2> will be $2. So when calling the second shell script, just pass those 2 positional shell parameters to the script when calling it like:
Code:
secondscript.ksh $1 $2

# 3  
Old 06-15-2010
Here is the example which is used

Please help me if I am missing out any.

INPUT file has similar to this...

Main script
Script=`basename $0`
IDWADMINMAIL="xxx@xx.com.au";
WDIR=/home/refresh
LogDir=${WDIR}/log
INPUT_FILE=${WDIR}/all.ksh
ProFILE=${WDIR}/process.log
cd ${WDIR}

while read line
do
####
#### We want to have a logfile for each load
####
PLog="${LogDir}/${Script}.log";
####
#### Need to keep creating DDL one after another
####
echo "${line}" >> ${ProFILE}
${line} >> ${PLog}
done < ${INPUT_FILE}
mailx -s "COMPLETED - DDL Transfer at `date '+%Y%m%d.%H%M'`" ${IDWADMINMAIL} << !!EOT

INPUT_FILE
Sub Script
ksh create_table_project_fromprod2dr.ksh $1 $2 > ItoFtbl.log 2>&1 &
ksh create_table_project_fromprod2dr.ksh $1 $2 > StoFtbl.log 2>&1 &
ksh create_table_project_fromprod2dr.ksh $1 $2 > BtoFtbl.log 2>&1 &
ksh create_table_project_fromprod2dr.ksh $1 $2 > TtoFtbl.log 2>&1 &
# 4  
Old 06-15-2010
I see none of the suggestions I made built into your script and you also ignored my bid to use code tags which you also got as PM with explanation how to use them.
What did you not understand what I wrote?
# 5  
Old 06-15-2010
I am trying to build a script which will around 10-15 main scripts one after another.

Basically two parameters are passed when running the shell script $1 & $2.

Also main shell script various for every 4 commands.

Suppose
ksh tbl.ksh $1 $2
ksh vw.ksh $1 $2
ksh mcr.ksh $1 $2
# 6  
Old 06-15-2010
Since you seem to ignore code tag requests and PMs and also give no answer to the suggestions for your problem made, you are collecting infraction points this way. When you have collected 30, you will be banned from the forum. I am not sure if this is your goal but I do not want to deprive this information.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

For-loop not working

Hello all, I would like to unzip some files with a for-loop. Is there anyone who could tell me how I should do this - in a correct way? for file in $(ls); do echo gzip -d < $file | tar xf -; done The problem is the pipe - I believe. But how could I do it? I need it for the command... (4 Replies)
Discussion started by: API
4 Replies

2. UNIX for Dummies Questions & Answers

for loop not working

Hi, I have ten different files to extract. so I thought for loop will help me. but it's not working for me. Please advice what I am doing wrong. for INCI in 1 2 3 4 5 6 7 8 9 10 do tar -xvf Update_INCI11.10.002_lnx86_1of10.tar done second file name is... (3 Replies)
Discussion started by: samnyc
3 Replies

3. Programming

C While Loop not working like C++

Hi new to C give me a hand thank. do { bzero(input,256); printf("Please enter the country name!"); scanf("%s",input); //& character is essential for scanf(), %f = float, %399s as the last character to be the null character ('\0'). } while... (5 Replies)
Discussion started by: GQiang
5 Replies

4. Shell Programming and Scripting

For loop not working

Hi All, For loop in ksh not working if it was given in the following method. simple script: for i in {1..4} do echo $i done Output: {1..4} Even below also not working :( Script: for (( c=1; c<=5; c++ )) do echo "Welcome $c times..." done Output: ./x.sh: 0403-057 Syntax error... (13 Replies)
Discussion started by: girish_satyam
13 Replies

5. Shell Programming and Scripting

while loop not working

hi everyone i am facing a very strange problem . please help me why my while loop is not working. below is my code #!/bin/ksh file=RCMC_ABC_999_080924_210813.DAR echo ${file} value=001 count=10 echo "abc" echo ${count} value=$((${value} + 1 )) echo ${value} while ] do echo... (3 Replies)
Discussion started by: aishsimplesweet
3 Replies

6. UNIX for Advanced & Expert Users

If loop is not working

The following piece of code is not running because it is fails to go inside the if condition. i want to create a directory if there is no directory in the input path. i am using Linux, by CENT. Please help. echo " Enter the path where you u want to extract the tar" read EXTRACT_PATH ls -ld... (12 Replies)
Discussion started by: toanilsharma1
12 Replies

7. UNIX for Dummies Questions & Answers

If then else loop not working

If then else segment of below code is not working. For each filename code is displaying output for if part as well as else part. Please help its urgent. for usercusttop in `echo ${filename}|sort|uniq|cut -c 1-${actualwordcount}` do ... (2 Replies)
Discussion started by: findprakash
2 Replies

8. Shell Programming and Scripting

For loop not working...! :(

Could some one help me on this... For loop is working...! for x in $i do for y in $j do z=`echo $y | awk '{print $2}'` if then FS=`/usr/bin/echo $y` echo $FS >>$Basic_location/out.csv fi done CPRT="Cpoyright @ BTOIDCIM" done (3 Replies)
Discussion started by: bullz26
3 Replies

9. Shell Programming and Scripting

if loop is not working

Hello i am trying to remove a line using an input file , but this depends upon user interaction here is the sample #!/bin/sh echo "Please enter whether you want to remove Profile" read value1 if ;then sed /movie/d temp.txt> temp3.txt else echo "Script didnot remove profile" fi ... (3 Replies)
Discussion started by: ranga27
3 Replies

10. Shell Programming and Scripting

Loop not working

Apologize if this is doesn't come under this group. I have a small script to find out users who last logged in to check there mail. (Tru 64 4.0, Netscape mail 3.6) -----> cat $1|awk -F: '$2=="SMTP-Accept" && $5~/@maildomain/ {s=$5;u++;las=substr($1)} END {for (i in u) {print... (2 Replies)
Discussion started by: nitin
2 Replies
Login or Register to Ask a Question