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
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)
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)
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)
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)
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)
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)
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)
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)
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)
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
LEARN ABOUT PHP
datetime.setdate
DATETIME.SETDATE(3) 1 DATETIME.SETDATE(3)DateTime::setDate - Sets the date
Object oriented style
SYNOPSIS
public DateTime DateTime::setDate (int $year, int $month, int $day)
DESCRIPTION
Procedural style
DateTime date_date_set (DateTime $object, int $year, int $month, int $day)
Resets the current date of the DateTime object to a different date.
PARAMETERS
o $object
-Procedural style only: A DateTime object returned by date_create(3). The function modifies this object.
o $year
- Year of the date.
o $month
- Month of the date.
o $day
- Day of the date.
RETURN VALUES
Returns the DateTime object for method chaining or FALSE on failure.
CHANGELOG
+--------+---------------------------------------------------+
|Version | |
| | |
| | Description |
| | |
+--------+---------------------------------------------------+
| 5.3.0 | |
| | |
| | Changed the return value on success from NULL to |
| | DateTime. |
| | |
+--------+---------------------------------------------------+
EXAMPLES
Example #1
DateTime.setDate(3) example
Object oriented style
<?php
$date = new DateTime();
$date->setDate(2001, 2, 3);
echo $date->format('Y-m-d');
?>
Procedural style
<?php
$date = date_create();
date_date_set($date, 2001, 2, 3);
echo date_format($date, 'Y-m-d');
?>
The above examples will output:
2001-02-03
Example #2
Values exceeding ranges are added to their parent values
<?php
$date = new DateTime();
$date->setDate(2001, 2, 28);
echo $date->format('Y-m-d') . "
";
$date->setDate(2001, 2, 29);
echo $date->format('Y-m-d') . "
";
$date->setDate(2001, 14, 3);
echo $date->format('Y-m-d') . "
";
?>
The above example will output:
2001-02-28
2001-03-01
2002-02-03
SEE ALSO DateTime.setISODate(3), DateTime.setTime(3).
PHP Documentation Group DATETIME.SETDATE(3)