Sponsored Content
Top Forums Shell Programming and Scripting Need help to understand ksh script Post 302514215 by gr8_usk on Friday 15th of April 2011 05:55:30 AM
Old 04-15-2011
Hi Mirni,

First up all thanks as lot for your quick reply to me.

Even I wondered about the same thing when I saw this code first time that from where it is getting input.

To put nmore focus on this, there is one function & into that function this code is present. Please see below code from begining,

Code:
sybSearch()
{
## changing current directory to that of the specified tree.
cd $TREE
cnt=`find ./ -name INSTALL\* -print -follow  2>/dev/null | wc -l | awk '{print $1}'`
if [ $cnt = 0 ]; then
        echo "\n============================================================================================" > $REPORT
        echo "There is no *INSTALL* file in this Package, please create one and resubmit your Package.." >> $REPORT
        echo "============================================================================================\n" >> $REPORT
        mailx -s "Scan Host: $HOST Tree: $TREE" "$MAILSTR" < $REPORT
        exit $VIOLATION
fi
## Preparing TEMP file
cat <<! > $TEMPSYB
[#]*use[#]*master[#]*$
[#]*use[#]*GDMGAdmin[#]*$
[#]*use[#]*GDMGSecurity[#]*$
[#]*use[#]*sybsecurity[#]*$
[#]*use[#]*sybsystemprocs[#]*$
[#]*use[#]*SEMSAuditDb[#]*$
sp_addlogin[#]*
sp_adduser[#]*
sp_addalias[#]*
sp_dropuser[#]*
sp_dropalias[#]*
sp_droplogin[#]*
sp_locklogin[#]*
sp_addgroup[#]*
sp_modifylogin[#]*
sp_changegroup[#]*
sp_addrole[#]*
sp_addrolemember[#]*
sp_droprole[#]*
^[#]*create[#]*role[#]*
^[#]*create[#]*database[#]*
[#]*grant.*to[#]*public[#]*
[#]*revoke.*from[#]*public[#]*
!
#[#]*grant.*to[#]*public[#]*$
#[#]*revoke.*from[#]*
###############################
#### Get list of all Tables
###############################
//g' | egrep -v '(.sh:|.ksh:)' | sed 's/^.*://g' | sed 's/^M//g' | grep -v '^[ /]*#' | egrep -i '(.dat|.ctl)' | sed -e 's/^.*=//g' -e 's/,/ /g' -e 's/;/ /g' -e 's/"//g' | tr ' ' '\n' | sed 's/[    ]*//g' | sed '/^$/d' | sort -u | awk -F"/" '{print $NF}' > $FILE
num_ctrl_files=0
OS=`uname`
if [ "$OS" = "SunOS" ]
then
//g' | egrep -v '(.sh:|.ksh:)' | sed 's/^.*://g' | sed 's/^M//g' | grep -v '^[ s]*#' | egrep -i '(.dat|.ctl)' | sed -e 's/^.*=//g' -e 's/,/ /g' -e 's/;/ /g' -e 's/"//g' | tr ' ' '\n' | sed 's/[    ]*//g' | sed '/^$/d' | sort -u | nawk -F"/" '{print $NF}' > $FILE
        num_ctrl_files=`wc -l $FILE | nawk '{print $1}'`
else
//g' | egrep -v '(.sh:|.ksh:)' | sed 's/^.*://g' | sed 's/^M//g' | grep -v '^[ s]*#' | egrep -i '(.dat|.ctl)' | sed -e 's/^.*=//g' -e 's/,/ /g' -e 's/;/ /g' -e 's/"//g' | tr ' ' '\n' | sed 's/[    ]*//g' | sed '/^$/d' | sort -u | awk -F"/" '{print $NF}' > $FILE
        num_ctrl_files=`wc -l $FILE | awk '{print $1}'`
fi

 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

import var and function from ksh script to another ksh script

Ih all, i have multiples ksh scripts for crontab's unix jobs they all have same variables declarations and some similar functions i would have a only single script file to declare my variables, like: var1= "aaa" var2= "bbb" var3= "ccc" ... function ab { ...} function bc { ... }... (2 Replies)
Discussion started by: wolfhurt
2 Replies

2. Shell Programming and Scripting

Can't understand the script

I am relatively new to Shell Scripting. I can't understand the following two scripts. Can someone please spare a minute to explain? 1) content s of file a are (021) 654-1234 sed 's/(//g;s/)//g;s/ /-/g' a 021-654-1234 2)cut -d: -f1,3,7 /etc/passwd |sort -t: +1n gives error (3 Replies)
Discussion started by: shahdharmit
3 Replies

3. Shell Programming and Scripting

Help to understand the script

Hi All; Is there anybody can explain this script please? trap 'C_logmsg "F" "CNTL/c OS signal trapped, Script ${G_SCRIPTNAME] terminated"; exit 1' 2 trap 'C_logmsg "F" "Kill Job Event sent from the Console, Script ${G_SCRIPTNAME] terminated"; exit 1' 15 (3 Replies)
Discussion started by: thankbe
3 Replies

4. Shell Programming and Scripting

Need to understand the script pls help

Can u please explain what it is doing #!/bin/sh fullyear=`/home/local/bin/datemmdd 1`"."`date +%Y` uehist=/u05/home/celldba/utility/ue/prod/history echo $fullyear cd $uehist ls -ltr pwroutages.master.$fullyear* | awk '{print $9}' > /u01/home/celldba/tmp/pwroutages_master_all_tmp while... (2 Replies)
Discussion started by: raopatwari
2 Replies

5. Shell Programming and Scripting

Help me understand the Perl script..

#!/usr/bin/perl use strict; use warnings; print "Demo of array slicing \n"; my @abc="a b c d e f g h i j k l m n o p q r s t u v w x y z"; my @a=@abc; my @random=@abc; my @comp=@abc; my @comp1=(@abc,"Hello",@abc); print "abc is @abc \n"; print "a is @a \n"; print "random is @random \n";... (1 Reply)
Discussion started by: dnam9917
1 Replies

6. Shell Programming and Scripting

Need help to understand this small script

Hi Guys, I need to understand below scipt:- -bash-3.00$ cat rsync-copy.ksh #!/usr/5bin/ksh batch <<%EOF% echo "/usr/local/bin/rsync --rsync-path=/usr/local/bin/rsync -a --stats /usr/openv/ /OpenvBCK" > openv.LOG # CG /usr/local/bin/rsync ... (6 Replies)
Discussion started by: manalisharmabe
6 Replies

7. Shell Programming and Scripting

Help to understand a script

Hello world! Can someone please explain me how this code works? I'ts supposed to find words in a dictionary and show the anagrams of the words. { part = word2key($1) data = $1 } function word2key(word, a, i, x, result) { x = split(word, a, "") asort(a) ... (1 Reply)
Discussion started by: jose2802
1 Replies

8. Shell Programming and Scripting

Need help to understand the below shell script

Please help me to understand the below 3 lines of code.execute shell in jenkins 1)APP_IP=$( docker inspect --format '{{ .NetworkSettings.Networks.'"$DOCKER_NETWORK_NAME"'.IPAddress }}' ${PROJECT_NAME_KEY}"-CI" ) 2)HOST_WORKSPACE=$(echo ${WORKSPACE} | sed... (1 Reply)
Discussion started by: naresh85
1 Replies

9. UNIX for Beginners Questions & Answers

Help me understand this script

#!/bin/awk -f BEGIN {i=1;file="modified.txt"} { if ($0 !~ /^DS:/) {print $0 >> file} else { if ($0 ~ /^DS:/) {print "DS: ",i >> file;if (i==8) {i=1} else {i++}}; } } END {gzip file} Can someone explain to me how this above script works, I got it from a friend but not able... (3 Replies)
Discussion started by: Kamesh G
3 Replies
echo(1B)					     SunOS/BSD Compatibility Package Commands						  echo(1B)

NAME
echo - echo arguments to standard output SYNOPSIS
/usr/ucb/echo [-n] [argument] DESCRIPTION
echo writes its arguments, separated by BLANKs and terminated by a NEWLINE, to the standard output. echo is useful for producing diagnostics in command files and for sending known data into a pipe, and for displaying the contents of envi- ronment variables. For example, you can use echo to determine how many subdirectories below the root directory (/) is your current directory, as follows: o echo your current-working-directory's full pathname o pipe the output through tr to translate the path's embedded slash-characters into space-characters o pipe that output through wc -w for a count of the names in your path. example% /usr/bin/echo "echo $PWD | tr '/' ' ' | wc -w" See tr(1) and wc(1) for their functionality. The shells csh(1), ksh(1), and sh(1), each have an echo built-in command, which, by default, will have precedence, and will be invoked if the user calls echo without a full pathname. /usr/ucb/echo and csh's echo() have an -n option, but do not understand back-slashed escape characters. sh's echo(), ksh's echo(), and /usr/bin/echo, on the other hand, understand the black-slashed escape characters, and ksh's echo() also understands a as the audible bell character; however, these commands do not have an -n option. OPTIONS
-n Do not add the NEWLINE to the output. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWscpu | +-----------------------------+-----------------------------+ SEE ALSO
csh(1), echo(1), ksh(1), sh(1), tr(1), wc(1), attributes(5) NOTES
The -n option is a transition aid for BSD applications, and may not be supported in future releases. SunOS 5.11 3 Aug 1994 echo(1B)
All times are GMT -4. The time now is 01:05 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy