Sponsored Content
Top Forums Shell Programming and Scripting Passing multiple run time arguments Post 302797653 by Prashanth B on Tuesday 23rd of April 2013 02:40:26 AM
Old 04-23-2013
If I pass 3 three arguments( run time) , it should take $1 and $2 and compare and should print the result as per below code
and in next run it should take $1 and $3 and do the same process and should print the result.how to rewrite the code so that
it runs for this scenario and also the path1 has many txt files and does details will be in
2 crtl files, so then it should run twice to compare and crtl and txt files. I need logic for that too.
But where I pass $3 value ?? If I pass besides $2 it throws $3 unexpected error.
If I pass 2 arguments ( run time) , it should take $1 and $2 and compare and should print the result as per below code

Code:
echo "Initialising the run time parameter for FOLDER path..." >file.log
path=$1
crtl=$2
crtl1=$3
cd $path
echo "\n Folder path of the unzipped files and CNTRL file: $1 ">>file.log
echo "\n \n Reading the content from CNTRL file and asssigning the values to variables...">>file.log
IFS='|'
while read -r fname Process_dt rec_cnt
do
        echo "\n $fname $Process_dt $rec_cnt ">>file.log
        echo "\n Checking if the File exist in the folder...">>file.log
 if [ -f $fname ]
        then
        echo "\n $fname Exist">>file.log
                echo "\n \n Reading linecount for the corresponding file and storing it in a variable...">>file.log
                cat $fname | wc -l | read linecount
                   echo $linecount
        echo "\n Reading Processdate for the corresponding file and storing it in a variable...">>file.log
echo $path
                case "$path" in
path)
ls -l path/$fname | grep -v total | awk '{print $6 " " $7 " " $8}'| nawk ' { months="  JanFebMarAprMayJunJulAugSepOctNovDec";date=$2;mo
nth=index(months,substr($1,1,3))/3;year=$3;printf("%02s/%02s/%04s\n",month,date,year)}'|read Proc_dt;;
path1)
ls -l path1/$fname | grep -v total | awk '{print $6 " " $7 " " $8}'| nawk ' { months="  JanFebMarAprMayJunJulAugSepOctNovDec";date=$2 -
1;month=index(months,substr($1,1,3))/3;year=$3;printf("%02s/%02s/%04s\n",month,date,year)}'|read Proc_dt;;
esac
                echo $Proc_dt>>file.log
                echo "\n checking if record count and Process date of the file matches with the CNTRL file entry...">>file.log
                        if [ $linecount -eq $rec_cnt ] && [ $Proc_dt = $(printf "%s" "$Process_dt") ]
                        then
                                        echo "\n \n Record Count and Process date matches from both files">>file.log
                        elif [ $linecount -ne $rec_cnt ]
                        then
                                      echo "\n \n Record Count doesnot match">>file.log
                        else
                                        echo "\n \n Process date doesnot match">>file.log
                        fi
        fi
        echo "Passing the run time parameter for CNTRL file name...">>file.log
done < $crtl $crtl1 #right way to pass 3 argument ??
echo " Filename,Record count and Process date validated against file $2">>file.log

and

Code:
sh validation.sh filename.crtl filename1.crtl

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to run multiple process at the same time

Hello guys, Look what im doing: I need to run a process from a SERVER1 to SERVER2, SERVER3 and SERVER4. The shell of the process is in each SERVER (2 to 4) So from SERVER1 i do: for i in SERVER2 SERVER3 SERVER4 do rsh $i ' ./process.sh ' done The problem is: each process.sh... (2 Replies)
Discussion started by: lestat_ecuador
2 Replies

2. UNIX for Dummies Questions & Answers

Help how replace stardard keyboard inputs by arguments at run time of a script

Hello Everybody, Please help. I was trying to automate the use of a third-party given shell script. The script is written to be used at run-time to collect a few variables to be provided by the user through key board, in the fashion as below: ./runcommand please provide a file name to... (6 Replies)
Discussion started by: Dingrong
6 Replies

3. Shell Programming and Scripting

Read multiple arguments in for loop each time

Hi, Guys I am new to shell programming and just get stuck with one simple question. please kindly help. According to the tutorial here, we can do something like for NODE in "ABC 10" "EFG 20" do set -- $NODE echo "letter is $1, number is $2" done And the result will... (3 Replies)
Discussion started by: yuanli
3 Replies

4. Shell Programming and Scripting

Run perl script with multiple file arguments

Hello everyone, I have two types of files in a directory: *.txt *.info I have a perl script that uses these two files as arguments, and produces a result file: perl myScript.pl abc.txt abc.xml How can I run this script (in a "for" loop , looping through both types of files)... (4 Replies)
Discussion started by: ad23
4 Replies

5. Shell Programming and Scripting

Help required in passing multiple arguments from a shell script to a pl/sql block

Hi, hope everyone are fine. Please find my issue below, and I request your help in the same In a configuration file, i have a variable defined as below TEST = 'One','Two','Three' I am trying to pass this variable in to a sql script which is define in a pl/sql block as follows, In the... (1 Reply)
Discussion started by: ramakanth_burra
1 Replies

6. UNIX for Dummies Questions & Answers

Passing arguments to alias with multiple commands

I have a few aliases set up on AIX servers in my .kshrc file. Some of them contain multiple commands that are piped together. A simple example would be something like this: # alias to list directory contents as root and sort by size. alias lss='sudo ls -l | sort -nbk5' When I call... (5 Replies)
Discussion started by: derndingle
5 Replies

7. Shell Programming and Scripting

Reading a string and passing passing arguments to a while loop

I have an for loop that reads the following file cat param.cfg val1:env1:opt1 val2:env2:opt2 val3:env3:opt3 val4:env4:opt4 . . The for loop extracts the each line of the file so that at any one point, the value of i is val1:env1:opt1 etc... I would like to extract each... (19 Replies)
Discussion started by: goddevil
19 Replies

8. Shell Programming and Scripting

Accepting multiple values in a variable at run time

Hi, Below is starting entry of my script #!/bin/ksh Usage() { print "Usage: $0 ID OPTION SERVER" print "<br>Where :" print "<br>Enter your ID into PARAM1, OPTION in the PARAM2 and SERVER in the PARAM3 field" print "<br>ID should be a valid ID" print "<br>OPTION should be either... (2 Replies)
Discussion started by: gopajitmalakar
2 Replies

9. Shell Programming and Scripting

Passing multiple arguments to a shell script

Hi Gurus, Need some help with the shell scripting here. #!/bin/ksh ps -ef | grep -i sample.ksh | grep -v grep > abc.txt if then echo "sample.ksh is executing" else echo "sample.ksh is not executing" fi (1 Reply)
Discussion started by: jayadanabalan
1 Replies

10. Shell Programming and Scripting

Passing multiple arguments

Hi, I know with getopts you can pass arguments from the command line ./script -ab -c apple But it doesn't support 2 or more arguments for ONE option. Is there any other way to do this? Thanks (2 Replies)
Discussion started by: testa500
2 Replies
DH_AUTORECONF(1)						   dh-autoreconf						  DH_AUTORECONF(1)

NAME
dh_autoreconf - Call autoreconf -f -i and keep track of the changed files. SYNOPSIS
dh_autoreconf [debhelper options] [-Xitem] [--mode=mode] [program -- params] DESCRIPTION
dh_autoreconf is responsible for calling autoreconf and creating the files debian/autoreconf.before and debian/autoreconf.after which contain checksums of all files before/after the build. It is complemented by dh_autoreconf_clean which creates a list of all changed and added files and removes them. Please note that dh_autoreconf can only be run once. Thus, if you need to run multiple commands, use a script or similar. An example is given in dh-autoreconf(7). FILES
debian/autoreconf This file can contain a list of directories. If present, dh_autoreconf will only scan the given directories for changes. If no special command is given to dh_autoreconf, it will also forward the directory list to autoreconf which causes it to be run only on those sub directories. OPTIONS
-Xitem --exclude=item Exclude files that contain "item" anywhere in their filename from being checked for changes. This means that those files won't be deleted by "dh_autoreconf_clean" even if there are changes. You may use this option multiple times to build up a list of things to exclude. Starting with version 3, the directories of common version control systems such as cvs, git, hg, svn, and bzr are excluded automatically. --mode=mode Change the way in which modifications to files are detected. The default mode is md5 for using MD5 checksums, but there is also timesize for using the time of the last modification and the file size. --as-needed Enable support for -Wl,--as-needed in all ltmain.sh files identical to the one of the libtool package. This only works in the MD5 mode (the default one). The changes are reverted in dh_autoreconf_clean. You should not prevent LIBTOOLIZE from running with this, as it only works correctly with libtoolize running. program -- params Run the program given by program with the arguments given by params instead of autoreconf -f -i. If you need to run multiple commands, put them in a script and pass the script instead (or add a target to debian/rules). ENVIRONMENT
For each tool executed by autoreconf(1), one can export a variable with the uppercase name of the tool to the specific program which shall be run, including true to prevent the tool in question from being run. The following example shows the beginning of a debian/rules for a package where automake 1.10 shall be run instead of the default automake version and libtoolize shall not be run: #!/usr/bin/make -f export AUTOMAKE = automake1.10 export LIBTOOLIZE = true SEE ALSO
debhelper(7), dh_autoreconf_clean(1), dh-autoreconf(7) AUTHOR
Julian Andres Klode <jak@debian.org> dh-autoreconf v7 2012-11-22 DH_AUTORECONF(1)
All times are GMT -4. The time now is 03:52 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy