Can't understand script output

New to korn shel1 and having an issue. The following is suppose to read the parameter values from files in a source directory and then pass them on to a log file in a different directory, The ArchiveTracker scripts is suppose to call the parameterreader script to exact the parameter values and pass them on to a log file.

But I keep getting the following when I run the script.

-bash: ./: is a directory

code

 #/bin/ksh
  
 #ArchiveTracker

SourceLocation='pwd'
 TrackerLocation=~/Scripts/Test/Tracker
  

 
  
 LOGFILE=$TrackerLocation/processing.log
  
 rm -f $LOGFILE
 touch $LOGFILE
  

 
 for sfile in $SourceLocation/*
 do
         if [ ! -s "$SourceLocation/$file" ];
         then
  
         echo Step 2: Processing $file >>  $LOGFILE
  
        while read line < $file
        do
                 PARNAME=`echo $line | awk -f "=" '{print  $1}'`
  
                 PARVALUE`parameterreader $file  $PARNAME`
                 echo  file $PARNAME >>  LOGFILE
         done
  
         sftp -p "$SourceLocation/$file  $TargetLocation/$file"
         ret_code=$?
         if [$ret_code != 0]; then
         printf "error : [%d] when executing command:"  $ret_code
         #exit $ret_code
         else
         echo Step 3: Writing  $TrackerLocation/$file
         touch "$TrackerLocation/$file"
         fi
 else
         echo Step 2: $file previously  processed
 fi
  
 done

code

code

#/bin/ksh
 #parameterreader script
  
  
 PARVALUE=`grep $2 $1 | awk -f "=" '{print  $1}'`
  
 echo $PARVALUE

code

it is hard to tell anything without way more info. Where - in which line - does the error occur? You say you're running ksh , but the error is from bash . What is PARVALUE in the first script supposed to be? Where is file set? And, if you intended to set a shebang in the first line of both scripts, the correct syntax is #!/bin/ksh .

1 Like

I have correct the portion identifying the script as ksh. But when should I include the PARVALUE variable within the first script. Script is running but always going to step portion of the script.

I assume that you meant for the code:

SourceLocation='pwd'

to set SourceLocation to the pathname of the current directory, but that is not what this code does. It sets SourceLocation to the literal string pwd .

Try this instead:

SourceLocation=$PWD

or one of the much slower options:

SourceLocation=$(pwd)

or (the less preferred form of command substitution):

SourceLocation=`pwd`

Note the huge difference in behavior between backquote ` and single-quote ' .

Then note that the code:

 for sfile in $SourceLocation/*
 do
         if [ ! -s "$SourceLocation/$file" ];
         then

is setting sfile as the loop control variable and using file inside the loop. And, that the if test is looking at the size of $SourceLocation/$SourceLocation/filneame . Maybe you meant something more like:

 for file in $SourceLocation/*
 do
         if [ ! -s "$file" ];
         then

If this still doesn't work turn on tracing so you can see what is happening as your script runs. You can run on tracing by invoking your script with:

ksh -xv scriptname

or by adding the following line as the second line of your script:

set -xv