In my a.KSH file this coding is present. I couldn't understand this. Please tell me the meaning of this coding.
file_size=`ls -l $1|awk '{print $5}' `
exit $file_size
I try a lot to understand, but couldn't.
In my a.KSH file this coding is present. I couldn't understand this. Please tell me the meaning of this coding.
file_size=`ls -l $1|awk '{print $5}' `
exit $file_size
I try a lot to understand, but couldn't.
this will echo the size of file passed as the commandline parameter.
it has two parts,
ls -l $1, this will get the listing for the file passed as parameter
awk...., this will get the 5th column from the ls -l $1 output which is the size of the file
Gaurav
Actually in another pro*c file this coding has written. The coding is
strcpy(size_script_path,getenv("COM_DIR"));
strcat(size_script_path,"/aa.ksh");
But in my KSH this coding is present.
file_size=`ls -l $1|awk '{print $5}' `
exit $file_size
I try a lot to understand, but couldn't.
So what this KSH is link to this pro*C program? If yes, how it is , please suggest me.
this is my interpretation may be wrong as well as I don't have any idea about pro*c
the pro*c code is calling this script to get the size of a file.
the script returns the size of the file.
Some details are missing from your description.
size_script_path contains the fully qualifies path to aa.ksh, provided the env variable COM_DIR was set appropriately.
Your mention of $1 says that took in some command line parameters for your shell script. Lets say, you passed in the contents of size_script_path to the script, file_size will hold the size of aa.ksh.
I dont understand how you related C calls and shell scripting together. Maybe I am missing something.
no one can undestand the program just by seeing 4 lines of code(of 2 different files).
I can guess that ur variable size_script_path contains the full path of script aa.ksh.
Your script(or may be function in the script) is returing the size of file.
Please be specific and clear when you are posting a question.
Ok, i will send the details of that program. But this is another KSH file, which i couldn't understand. The full code, i have given here. i.e.,
#!/bin/ksh
cd /ngs/dep/debppp/rel3321-B03/bin
./startserver >/dev/null
cd /ngs/deb/debppp/rel3321-B03-8606/bin
./startserver >/dev/null
cd /ngs/deb/debppp/rel3321-B03-8608/bin
./startserver >/dev/null
Make an effort and tell us what you understood from the code and then let us know which part of it is not clear.
i couldn't understand at all
Go into each of the bin directories and run the program startserver. All stdout would go into /dev/null and all stderr would output on the terminal i.e. if any error messages are thrown, you will see them. If any normal non-error messages are present you will not see them.
Thanks for given solution.
Please tell me the meaning of this programme. The coding is in below.
initialize_variables()
{
# initialise the variables
export R_HOME=`echo $HOME`
export RELEASE_HOME =$R_HOME/RELEASE
export RELEASE_LOG_DIR=$RELEASE_HOME/log
export REPORTS_HOME = $R_HOME/reports_home
export REPORTS_HOME_LOG = $REPORTS_HOME/log
export REPORTS_HOME_TMP = $REPORTS_HOME/tmp
export REPORTS_HOME_REPORT = $REPORTS_HOME/report
export R_3.4.4=$R_HOME/R3.4.4
export LOG_FILE=$R_3.4.4/tmp/r.log
export R_3.4.4_LOG=$R_3.4.4/log
export CLASSES_DIR=$R_3.4.4/jars/ETicket
export CLASSPATH=$CLASSES_DIR:$CLASSES_DIR/ETicket:$CLASSES_DIR/ETicket/ETicketClient.jar
}
on_exit()
{
if [ $1 -ne 0 ]
then
echo "Encountered some problems in processing" >>$LOG_FILE
raise ticket
echo "Raising Ticket for log file processing i.e. delete and moving the log files " >>$LOG_FILE
cd $CLASSES_DIR/ETicket
java ETicket.ETicketClient -i TICKET -n "debpr\_p\_p\_cleanup_rlogs" -j p -r 3 -t "server logs" -f f -d "Error in deleting the server logs" >>$LOG_FILE
cd \-
echo "Done" >>$LOG_FILE
cd $cur_dir
else
echo "Sucessfully completed the job" >> $LOG_FILE
fi
exit $1
}
#================================================================================
# Main code starts here
#================================================================================
#initialising variables
initialize_variables
if [ -d $RELEASE_LOG_DIR ]
then
cd $RELEASE_LOG_DIR
echo $RELEASE_LOG_DIR >> $LOG_FILE
find . \( -name '*.log*' -type f \) -mtime +30 -exec rm -f {} \;
fi
if [ $? -ne 0 ]
then
echo "Error occured in deleting files from log directory" >> $LOG_FILE
on_exit 1
else
echo "Successfully deleted files from log directory" >> $LOG_FILE
on_exit 0
fi
if [ -d $REPORTS_HOME_LOG ]
then
cd $REPORTS_HOME_LOG
echo $REPORTS_HOME_LOG >> $LOG_FILE
find . \( -name '*.log' -type f \) -mtime +30 -exec rm -f {} \;
fi
if [ $? -ne 0 ]
then
echo "Error occured in deleting files from log directory" >> $LOG_FILE
on_exit 1
else
echo "Successfully deleted files from log directory" >> $LOG_FILE
on_exit 0
fi
if [ -d $REPORTS_HOME_TMP ]
then
cd $REPORTS_HOME_TMP
echo $REPORTS_HOME_TMP >> $LOG_FILE
find . \( -name '*.txt' -type f \) -mtime +60 -exec rm -f {} \;
fi
if [ $? -ne 0 ]
then
echo "Error occured in deleting files from log directory" >> $LOG_FILE
on_exit 1
else
echo "Successfully deleted files from log directory" >> $LOG_FILE
on_exit 0
fi
if [ -d $REPORTS_HOME_REPORT ]
then
cd $REPORTS_HOME_REPORT
echo $REPORTS_HOME_REPORT >> $LOG_FILE
find . \( -name '*.xls' -type f \) -mtime +60 -exec rm -f {} \;
fi
if [ $? -ne 0 ]
then
echo "Error occured in deleting files from log directory" >> $LOG_FILE
on_exit 1
else
echo "Successfully deleted files from log directory" >> $LOG_FILE
on_exit 0
fi
if [ -d $R_3.4.4_LOG ]
then
cd $R_3.4.4_LOG
echo $R_3.4.4_LOG >> $LOG_FILE
find . \( -name '*.log' -type f \) -mtime +15 -exec rm -f {} \;
fi
if [ $? -ne 0 ]
then
echo "Error occured in deleting files from log directory" >> $LOG_FILE
on_exit 1
else
echo "Successfully deleted files from log directory" >> $LOG_FILE
on_exit 1
fi