ERROR: Required Parameters Missing


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting ERROR: Required Parameters Missing
# 1  
Old 07-29-2014
ERROR: Required Parameters Missing

i have modified a korn shell script to include a parameter and i coded the parameter as
Code:
pSec=$1
pLoopCnt=$2

wheni run the script it gives me an error
Code:
$ ksh sfs_pcard_load_file.ksh 30 3
ERROR: Required Parameters Missing.
USAGE: sfs_pcard_load_file.ksh

please help i think i might have incorrectly declare the paramter.

thanks,
warren

Last edited by Scott; 07-29-2014 at 06:18 PM.. Reason: Code tags
# 2  
Old 07-29-2014
Difficult to tell unless you post the relevant part of the script in code tags.
This User Gave Thanks to RudiC For This Post:
# 3  
Old 07-29-2014
Code:
#!/usr/bin/ksh
#
# Check for required number of parameters if any are expected
#--------------------------------------------------------------------
#
if [[ $# != 0 ]]; then
  print "ERROR: Required Parameters Missing."
  print "USAGE: `basename $0`"
  exit 1
fi
#
#####################################################################
#
# Initialization file
#--------------------------------------------------------------------
. ./pcard_load_data.ini

#####################################################################
#
# Parameter definition
#--------------------------------------------------------------------
pSec=$1
pLoopCnt=$2
#
#####################################################################
#
# Variable Initialization
#--------------------------------------------------------------------
#
CURDATE=`date +%m/%d/%Y" "%H:%M:%S`
#LOGDATE=`date +%m%d%Y"_"%H%M%S`
LOGDATE=`date +%m%d%Y"`
JOBNAME=`basename $0 | cut -d. -f1`
LOG_FILE=${LOG_DIR}/${JOBNAME}_${LOGDATE}.log
LOG_FILE_ERROR=${LOG_DIR}/${JOBNAME}_${LOGDATE}_err.log
ORALOGFILE=${LOG_DIR}/PCARDDAILY${LOGDATE}.log

# log file header
echo "+------------------------------------------------------------+" >> $LOG_FILE
echo "This is the log file of pcard_load_file.ksh script"  >> $LOG_FILE
echo "Run date: $CURDATE\n" >> $LOG_FILE

#
#####################################################################
#
# Step: 1
#
# Check for already running process and any files to process
#
#--------------------------------------------------------------------
#
echo "Step 1 Start..." >> $LOG_FILE
ctr=0
while [ ${ctr} -lt ${pLoopCnt} ] 
do
  ISRUNNING=`ps -eaf -o args | grep -i sfs_pcard_load_file.ksh | grep -v grep | wc -l`
  ctr=$(($ctr + 1))
  if (( ${ISRUNNING} > 1 )); then
    echo "ERROR: Process is already running." >> $LOG_FILE
    echo "Please Contact Application Administrator" >> $LOG_FILE
    sleep $pSec
    echo "number of attempt $ctr" >> $LOG_FILE
    #exit 1
    if ((${ctr} == ${pLoopCnt})) then
      exit 1
    fi
  else
    exit 0
  fi
done
#
NUMFILES=`ls -1 $INPUT_DIR | wc -l`
 if (( ${NUMFILES} == 0 )); then
   echo "WARNING: There are no files in input directory to process.\n" >> $LOG_FILE
   exit 1
 fi
echo "End of Step 1\n" >> $LOG_FILE
#
#####################################################################
#
# Step: 2
#
# Process files in INPUT_DIR
#
#--------------------------------------------------------------------
#
echo "Step 2 Start...\n" >> $LOG_FILE
cd $INPUT_DIR
#
NUMFILES=`ls -1 *.csv | wc -l`
 if (( ${NUMFILES} == 0 )); then
   echo "WARNING: There are no files in process directory.\n" >> $LOG_FILE
   #if there are no input files there will be no output file to be created
   #needs to create a null output file
   cp pcard.null PCARDDAILY${LOGDATE}.txt
   echo "         Created the $INPUT_DIR/PCARDDAILY${LOGDATE}.txt null file to replicate the required file.\n" >> $LOG_FILE
   #needs to create a database log file PCARDDAILY${LOGDATE}.log
   echo "WARNING: There are no extracted files.\n" >> $ORALOGFILE
   exit 0
 fi
#
 for filename in $(ls -1 *.csv)
 do
  echo "Processing $filename \n" >> $LOG_FILE
  #
  echo "Copied $filename to log directory: $LOG_DIR\n" >> $LOG_FILE
  cp $filename $LOG_DIR
  #
  echo "Executed PL/SQL package for $filename\n" >> $LOG_FILE
  SQL_LOG_FILE=${LOG_DIR}/${filename}_${LOGDATE}.log
  DB_RSLT=`sqlplus -s <<EOF >> $SQL_LOG_FILE
   $USERID
   --set head off
   --select '$filename' from dual;
   --set serveroutput on
   declare
    v_result varchar2(200);
   begin
    cca_app.Pa_SFS_PCARD_Daily_Bulkload.Pr_Daily_Process('$filename');
   end;
/ 
   exit 0
  EOF`
  wait
  #
  RC=$?
  #
  echo $DB_RSLT >> $LOG_FILE
  echo "Deleted $filename from $INPUT_DIR\n" >> $LOG_FILE
  rm -f $filename
  #
 done
 echo "End of Step 2\n" >> $LOG_FILE

#
#####################################################################
#
# Step: 3
#
# check for file PCard (Output PCARDDAILY*.txt) 
#
#--------------------------------------------------------------------
#
echo "Step 3 Start...\n" >> $LOG_FILE
cd $INPUT_DIR
#
NUMFILES=`ls -1 PCARD*.txt | wc -l`
 if (( ${NUMFILES} == 0 )); then
   echo "WARNING: There are no PCARD*.txt files in the output $INPUT_DIR directory.\n" >> $LOG_FILE
   cp pcard.null PCARD${LOGDATE}.txt
   echo "         Created a PCARD${LOGDATE}.txt null file to replicate the file.\n" >> $LOG_FILE
   exit 1
 fi
#


#
#####################################################################
#
# Step: 4
#
# delete files from log and completed dir > 30 days old   
#
#--------------------------------------------------------------------
#
echo "Step 4 Start...\n" >> $LOG_FILE
#
cd $LOG_DIR
find . -name "*.csv" -mtime +30 -exec rm -f {} \;                 
cd ${LOG_DIR}                                                                  
find . -name "*.log" -mtime +30 -exec rm -f {} \;                 
#
 echo "End of Step 4\n" >> $LOG_FILE
#
exit 0


in the above code i added the parameters
pSec=$1
pLoopCnt=$2
and use them in the while ... loop. the idea was to accept a parameter in seconds and number of times the loop will execute. for example loop 10 times in 30 seconds.

thanks.

Last edited by wtolentino; 07-29-2014 at 04:26 PM..
# 4  
Old 07-29-2014
Et voila: look at line 6: if [[ $# != 0 ]]; then This script does NOT accept any parameters!
Comment out that paragraph and try again.
This User Gave Thanks to RudiC For This Post:
# 5  
Old 07-29-2014
that works thank you
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Error in ksh script: missing right bracket

I have no idea how to write ksh script, but i'm really in need of help with this. I using fedora 30 and in attempt of runnig attached script i getting those errors, i solved first error by removing excess bracket, but i do not know what should i do with other. Pls sorry for trash post. (8 Replies)
Discussion started by: NullPtr
8 Replies

2. UNIX for Beginners Questions & Answers

Missing argument for option: n Error

I am trying to execute the cli.sh script in another shell script passing arguments and getting the below error. Myscript.sh #!/bin/sh /home/runAJobCli/cli.sh runAJobCli -n $Taskname -t $Tasktype I am passing the below 2 arguments and it giving error ./Myscript.sh T_SAMPLE_TEST MTT... (11 Replies)
Discussion started by: Info_Geek
11 Replies

3. Red Hat

Missing the MySQL extension which is required by WordPress.

hi i started in the apache userdirectory and virtual host now iwant installtion wordpress in home one of the useres But this error is Your PHP installation appears to be missing the MySQL extension which is required by WordPress. And the configuration files and other items I was enter... (0 Replies)
Discussion started by: mnnn
0 Replies

4. Shell Programming and Scripting

[: ']' missing Error is coming

Hi guyz, i m new to UNIX (ksh) shell scripting. while running simple code i m getting error. read opt1 read opt2 if && ]; then echo "Yes" fi while running i m getting the below error. 0 YES ./ifelse.ksh: ' missing ./ifelse.ksh: 0: not found ./ifelse.ksh: 0: not found ... (4 Replies)
Discussion started by: Jonty Immortal
4 Replies

5. UNIX for Dummies Questions & Answers

Perl Script:how to find how many parameters are required to run the script

How to find how many parameters are required to run a Perl script? (1 Reply)
Discussion started by: Lakshman_Gupta
1 Replies

6. Shell Programming and Scripting

Incorrect number of command line arguments and missing required files

I am developing a script. This script takes in one parameter which is the name of a file whose content is a list of names of some files. The script can check whether those files exist in current directory. Here is my question: If the number of provided parameters is less than one or one of the... (2 Replies)
Discussion started by: Ray Sun
2 Replies

7. Shell Programming and Scripting

Missing ] error in csh script

The below script gives error: Missing ] #!/bin/csh set MAX=15 set PATTERN='dtsession' set NUM=`ps -eaf | grep -c $PATTERN` echo "No of dtsession = "$NUM if then echo 'Quota exceeded permissible limit' echo 'sending mail...............' mail hiten.r.chauhan@gmail.com<<EOF ... (2 Replies)
Discussion started by: hiten.r.chauhan
2 Replies

8. Shell Programming and Scripting

Error : [: missing `]'

Hi, I am attempting to test the input value for an integer. And if the value is not an integer, the intent is to complain about it and exit. Only if I can get past the syntax error, life will be full. # test input to be a number +$'; ] && { echo "Invalid input; Enter an integer..."; exit 2; }... (7 Replies)
Discussion started by: IETF
7 Replies

9. AIX

tuning network parameters : parameters not persist after reboot

Hello, On Aix 5.2, we changed the parameters tcp_keepinit, tcp_keepintvl and tcp_keepidle with the no command. tunrestore -R is present in inittab in the directory /etc/tunables we can clearly see the inclusion of parameters during reboot, including the file lastboot.log ... (0 Replies)
Discussion started by: dantares
0 Replies

10. UNIX for Dummies Questions & Answers

Help required on Printing of Numbers, which are missing in the range

Hi Experts, Need help on printing of numbers, which are missing in the range. Pls find the details below Input 1000000002 1000000007 1234007940 1234007946 Output 1000000003 1000000004 1000000005 1000000006 1234007941 (2 Replies)
Discussion started by: krao
2 Replies
Login or Register to Ask a Question