having problem while executing the script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting having problem while executing the script
# 1  
Old 02-22-2012
having problem while executing the script

Hi i am getting stuck while executing the script in the below line .Please help me out

Code:
if [ "$Nam" = "" ];then
  Name=`grep -i $Size $FILE|awk '{print $(NF-1),$NF}' |head -1`
else
  Name="$Nam"       
fi


Last edited by Scott; 02-22-2012 at 06:43 AM.. Reason: Please use code tags
# 2  
Old 02-22-2012
what is the error you are getting ?

what is there in $Size and $FILE and $Nam ?

Code:
 
echo $Size
echo $FILE
echo $Nam

# 3  
Old 02-22-2012
Code:
for i in $BATCH_LIST
do
  rm -f file*
  awk '/^-/{close("file"f);f++}{print $0 > "file"f}' $i
  BN=`grep -i ^START file|awk '{print $3}'`
  #echo "\nBatch Name : $BN\n" >> Daily.txt
  FILE_LIST=`ls -l file*|sed '1d'|awk '{print $9}'`
  for FILE in $FILE_LIST
  do
    No=`grep -i Rapport $FILE|awk '{print $2}'`
    Nam=`grep -i output  $FILE|cut -d"/" -f7`
    Size=` grep -i bytes  $FILE|awk '{print $(NF-1)}'|head -1`
    Start_Time=`sed -n '/^0/p' $FILE|head -1`
    End_Time=`sed -n '/^0/p' $FILE|head -2|sed '1d'`
    Result=`grep -i Mailing $FILE|awk '{print $(NF-1),$NF }'`

    if [ "$Result" = "$R1" ];      
    then
      Result="SUCCESS"
    elif [ "$Result" = "$R2" ];
    then
      Result="FAILED"
      echo "$BN  $Name $Start_Time  $End_Time"> t.txt
      awk '{printf "%-20s  %-62s  %-9s %-9s\n",substr($1,1,20),substr($2,1,62),$3,$4}' t.txt >> f.txt
    else
      Result="N/A"
    fi
  done # i am trying to executing the following code but it was halt here in
  if [ "$Nam" = "" ];then
    Name=`grep -i $Size $FILE|awk '{print $(NF-1),$NF}' |head -1`
  else
    Name="$Nam"       
  fi

so can you let me know how to resolve this issue

Last edited by Scott; 02-22-2012 at 06:50 AM.. Reason: Please use code tags and format your posts better
# 4  
Old 02-22-2012
Code:
 
for i in $BATCH_LIST
do
 rm -f file*
 awk '/^-/{close("file"f);f++}{print $0 > "file"f}' $i
 BN=`grep -i ^START file|awk '{print $3}'`
 FILE_LIST=`ls -l file*|sed '1d'|awk '{print $9}'`
 
 for FILE in $FILE_LIST
 do
  No=`grep -i Rapport $FILE|awk '{print $2}'`
  Nam=`grep -i output $FILE|cut -d"/" -f7`
  Size=` grep -i bytes $FILE|awk '{print $(NF-1)}'|head -1`
  Start_Time=`sed -n '/^0/p' $FILE|head -1`
  End_Time=`sed -n '/^0/p' $FILE|head -2|sed '1d'`
  Result=`grep -i Mailing $FILE|awk '{print $(NF-1),$NF }'`
  
  if [ "$Result" = "$R1" ]; 
  then
   Result="SUCCESS"
  elif [ "$Result" = "$R2" ];
  then
   Result="FAILED"
   echo "$BN $Name $Start_Time $End_Time"> t.txt
   awk '{printf "%-20s %-62s %-9s %-9s\n",substr($1,1,20),substr($2,1,62),$3,$4}' t.txt >> f.txt
  else
   Result="N/A"
  fi
 done # here you are closing the second for loop, then how the $FILE and other vairbles will be available ?
 #i am trying to executing the following code but it was halt here in 
 
 if [ "$Nam" = "" ];then
  Name=`grep -i $Size $FILE|awk '{print $(NF-1),$NF}' |head -1`
 else
  Name="$Nam" 
 fi

---------- Post updated at 04:15 PM ---------- Previous update was at 04:12 PM ----------

it will hold the last values of the loop

$Size $FILE $Nam

as you are closing the for loop.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

problem in Executing script in ksh

Hi, I am in ksh. below mentioned 3 commands I executed at command prompt & got the expected results. csh source csh_infa <special command> Now I have to do this in the script in ksh. I entered it as it is. #!/bin/ksh csh source csh_infa <special command> Now after... (1 Reply)
Discussion started by: girish_kanak
1 Replies

2. Homework & Coursework Questions

Problem with executing a possible if or case statement script

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Create a phonebook program. It should use functions to perform the required tasks. It should be menu-based,... (1 Reply)
Discussion started by: Rgasin02
1 Replies

3. UNIX for Dummies Questions & Answers

Error Executing a script(SSH problem)

Hi i m writing a script which will fetch data from different machines and display it on single terminal. I have created a file named SERVERNAMES containing ip address of machines i need to monitor. Then for every IP i m issuing ssh command to get date on that machine. However When i m trying... (3 Replies)
Discussion started by: pinga123
3 Replies

4. Shell Programming and Scripting

Problem with executing a shell script through the cron

Hi, I have a shell script as below: ORACLE_HOME=/usr/local/opt/oracle/product/dev export ORACLE_HOME PATH=$PATH:$ORACLE_HOME/bin:/usr/bin export PATH OUTFILE=/export/home/`basename $0`.out export OUTFILE export IDEN df -k . | tail -1 | read a b c d e f echo $a >> $OUTFILE echo $b... (4 Replies)
Discussion started by: Abhinav Pandey
4 Replies

5. Shell Programming and Scripting

Problem executing a script

Hi Friends, When I try to execute one of my script script1.shl, I am getting the error message as "/tmp/sh1871978.13: cannot create" . I could not find the specified sh* file in the /tmp directory and I also checked the disk space of /tmp and it is only 60% filled. Please help me on... (5 Replies)
Discussion started by: mr_manii
5 Replies

6. Shell Programming and Scripting

Problem executing script through at

Hey fellows, i've got a probkem while executing a command through a scheduled at-job; Somehow my script starts looping, when triggered throug at; It doesnt do so if started manually. Any ideas? #!/bin/sh # atrun uid=33 gid=33 # mail www-data 0 umask 22 cd /var/django/webripper/ripper... (2 Replies)
Discussion started by: viktor4124
2 Replies

7. Shell Programming and Scripting

Problem with executing script using ssh

I'm writing a script which is meant to ssh into a remote machine, sed a file there, and write the output to a new file on the remote machine. Obviously the easy way to do this is to write and execute the script on the remote machine, but I'm trying to do this all via ssh since I like to keep and... (4 Replies)
Discussion started by: maethlin
4 Replies

8. Shell Programming and Scripting

Problem executing a script

The script startserver.sh has permissions to execute. Still the nohup command returns error with 'No such file or directory' Any sugggestions: $ nohup ./startserver.sh & Error $ nohup: appending output to `nohup.out' nohup: cannot run command `./startserver.sh': No such file or... (4 Replies)
Discussion started by: hemangjani
4 Replies

9. Shell Programming and Scripting

Problem with executing a script scheduled in crontab

Hi I have written a shell script(in Solaris) in which following logic is there..... i=1 while read control do key=`echo $control | awk -F$DELIMITOR '{ print $1 }'` echo "Key Values" ${key} i=`/usr/bin/expr $i + 1` done < $CONFPATH/$CONFFILE when i execute it at prompt it... (4 Replies)
Discussion started by: Amardeep
4 Replies

10. Shell Programming and Scripting

Problem executing setuid script in perl-5.8.6

Hi, I have a script (a.pl) that can be run by anyone. The script internally has to read a file and write into few files which are owned by user 'myUser'. Has to read the following file: -rwx------ 1 myuser myuser 4986 Aug 20 18:11 my.file Has to write into following files: ... (0 Replies)
Discussion started by: sarmakdvsr
0 Replies
Login or Register to Ask a Question