Tag Archives: ERROR

How to exit a script with error ?

By Salil Gupta

Hi,

I have a script ABC which calls another script XYZ. Function of XYZ is to ftp a file from one server to another.

code for ABC:

Code:

#!/bin/ksh
PATH=/usr/bin

home/user/xyz "$@"

exit $?
~


code for xyz:

Code:

#!/bin/ksh
HOSTNAME=$1
SRCNAME=$2
DSTNAME=$3

### This file holds the outget of the FTP commands for success checking
FTPCHK=/tmp/ftpchk.$$
#touch $FTPCHK
echo "" > $FTPCHK

SRCFILE=$SRCNAME

DSTFILE=$DSTNAME

echo Source Host: $HOSTNAME
echo Source File Name: $SRCFILE
echo Destination File: $DSTFILE

echo `date` Beginning FTP download...
ftp -v ${HOSTNAME} <>$FTPCHK 2>&1
ascii
nlist ${SRCFILE}
get ${SRCFILE} ${DSTFILE}
quit
EOF

### Check for FTP errors
CHK1=`grep -c "226 Transfer complete." $FTPCHK`
CHK2=`grep -c "226 ASCII Transfer complete." $FTPCHK`
CHK3=`grep -ic "226 transfer complete" $FTPCHK`
CHK4=`grep -ic "226 File send OK." $FTPCHK`

### In NT, There should transmissions complete:
### One for the data transfer,
### One for the nlist

if [ $CHK1 -eq 2 ] || [ $CHK2 -eq 2 ] || [ $CHK1 -eq 1 -a $CHK2 -eq 1 ] || [ $CHK3 -eq 2 ] || [ $CHK4 -eq 1 ]; then
RC=0
echo "OK: FTP Transmission Worked"
echo '--------------------------------------------------------------'
cat $FTPCHK
echo '--------------------------------------------------------------'

else
RC=1
echo "ERROR: FTP Transmission Failed"
banner "ERROR"
echo '--------------------------------------------------------------'
cat $FTPCHK
echo '--------------------------------------------------------------'
fi

date
ls -al ${DSTFILE}

rm $FTPCHK

echo '---------------------------------------------------------------------'

exit $RC


In script XYZ, I am trying to ftp a file. So during ftp , whenever it shows that space is less than size of file, it should ftp the partial according to the available space and prompt a message about it and also prompt a message to outer script that inner script could not complete successfully. Hence resulting in the failure of outer script, due to partial ftp of file.

Also please post the comments about the each step of script to explain what is happening in that step. Thanks a lot in advance.

…read more

Source: FULL ARTICLE at The UNIX and Linux Forums

AIX idea needed to check the logs updated date and time

By Kalaihari

Hi with the help of Gabriel canepa, i have just edited filename only in his code. The help which i got and he helped is
1) I have around 22 logs and each log should be updated in the last 24 hours from the current timestamp.
2) It should check for ERROR message (not error,Error) in the log and if it founds the ERROR means it should send us an update on that.

He has developed a script brilliantly for my sake and the problem is he developed in linux terminal. I have a problem running in my AIX terminal.

The code is as follows:
#!/bin/bash
mailcontents=mailbody
while read line
do
if [ ! -f $line ]; then
echo “The file $line doesn’t exist. Continuing with the next file…” >> $mailcontents
echo “============” >> $mailcontents
continue
else
last_mod_time=$(stat -c ‘%Y’ $line) # this line checks the log’s last modification time and converts it to Unix’s epoch
last_24_hours=$(date +%s -d “24 hours ago”) # this line returns the epoch for the current timestamp minus 24 hours

if [ $last_mod_time -lt $last_24_hours ]; then
echo “Log $line has NOT been updated in the last 24 hours” >> $mailcontents
else
echo “Log $line was updated during the last 24 hours” >> $mailcontents
fi

tail -100 $line > checklog

error=$(grep ERROR checklog | wc -l) # We look for the lines containing the word “ERROR” in the checklog file.
# Then we redirect the output to the wc -l command that will count the number
…read more

Source: FULL ARTICLE at The UNIX and Linux Forums

To display 10 lines before and after the error

By ajothi

Hi,

I have a huge log file and I wanted to check for the errors which happened on the particular time frame- Since its huge – vi is making difficult for me
So I used the below command to
grep -i ‘ERROR‘ wls.log | grep ‘Apr 8’

which showed there were few errors

Is there some way, we can also get the 10 lines before and after the error?
Thanks in advance!

From: http://www.unix.com/shell-programming-scripting/221413-display-10-lines-before-after-error.html

How to go to a line having a particular word?

By twistedpair

Hi all,
I want the cursor to go to a line having a particular word (: ERROR). and that line should have the first occurrence word(: ERROR) from the beginning of the gvim file(*.SUM*)
Presently iam using the following command.But the cursor is going to the second occurrence of the word (: ERROR)
autocmd BufReadPost *.SUM* /: ERROR
Plz help me out

…read more

Source: FULL ARTICLE at The UNIX and Linux Forums

Samba 4 error

By Vaibhav.T

Hi guys

i am using samba 5.9.I have downloaded samba 4 and other dependencies i.e.
glibc glibc-devel gcc python* libacl-devel krb5-workstation krb5-libs pam_krb5

trying to configure active directory feature for my small network.when i type
command /usr/local/samba/samba-tool domain provision its showing error :


ERROR(exceptions.TypeError): uncaught exception – __init__() got an unexpected keyword argument ‘epilog’
File “/usr/local/samba/bin/samba-tool”, line 45, in ?
retval = cmd._run(“samba-tool”, subcommand, *args)
File “/usr/local/samba/lib64/python2.4/site-packages/samba/netcmd/__init__.py”, line 215, in _run
parser, optiongroups = self._create_parser(myname, epilog=epilog)
File “/usr/local/samba/lib64/python2.4/site-packages/samba/netcmd/__init__.py”, line 130, in _create_parser
prog=prog,epilog=epilog)

please help me out.

vaibhav

…read more
Source: FULL ARTICLE at The UNIX and Linux Forums

How to validate user's input..?

By Rashid Khan


$Input_filename=$ARGV[0];

if (!-d $Input_filename && ! -e $Input_filename)
{
print "USAGE: Please enter '$ABCD/def/dsed.txt' as an arguement n";
exit;
}


1. Input Is suppose to be something like “$ABCD/def/dsed.txt”.
if the input is wrong the script should throw an ERROR message.

if user enters $ABCD only, error message should be displayed.

if the user enters “$ABCD/def/” a error message shold be displayed.

do i need any regex to check it out??

PLEASE SUGGEST…..

…read more
Source: FULL ARTICLE at The UNIX and Linux Forums

To exclude a string from monitoring

By ajothi

Hi below is my current scripting which will monitor for any errors in the application

logfile=”/tmp/application.log”
output=$(grep “ERROR” $logfile)
if [ -n “$output” ]
then
echo “found- send email”
else
echo “not found”
fi

Now I wanted the script not to send the email for one of the occurence which is a known issue
Could you please help me as how can I set this up
The error string I wanted to exclude from monitoring is below

ERROR – Error while reading from socket
java.net.SocketException: Connection reset “

…read more
Source: FULL ARTICLE at The UNIX and Linux Forums

$ symbol in sql query in shell script

By indira_s

Hi Team,

Can you please help me to resolve this issue.

Am unable to use this $ symbol in sql query in the shell script.

For Example:

# !/bin/sh

export USER_NAME=XXX
export PASSWORD=YYY

export ORACLE_SID=xamdb
echo $ORACLE_SID

echo ” Session Details …”

DATE_TIME=`date +%Y%m%d_%H%M%S`
echo $DATE_TIME

#`$ORACLE_HOME/bin/
sqlplus $USER_NAME/$PASSWORD@xamdb << EOF
set serveroutput on
set feedback off

SELECT count(1) AS con_count, machine, username , osuser, status
FROM v$session
WHERE type ‘BACKGROUND’
GROUP BY username, machine ,osuser, status
ORDER BY con_count DESC;

END;
/
EOF

echo “Completed Session details…”

Output:
======
SQL> SQL> SQL> SQL> SQL> 2 3 4 5 FROM v
*
ERROR at line 2:
ORA-00942: table or view does not exist

SQL> SQL> SP2-0042: unknown command “END” – rest of line ignored.
SQL> FROM v
*
ERROR at line 2:
ORA-00942: table or view does not exist

———- Post updated at 05:22 PM ———- Previous update was at 05:11 PM ———-

I got the answer. we should use symbol.
SELECT count(1) AS con_count, machine, username , osuser, status
FROM v$session
WHERE type ‘BACKGROUND’
GROUP BY username, machine ,osuser, status
ORDER BY con_count DESC;

…read more
Source: FULL ARTICLE at The UNIX and Linux Forums

Error in while loop

By netdbaind

I have a file Table.out having table name like this

Code:

Table_Emp
Table_Exp
Table_Fcr


To show first 10 rows .. I’ wrtng a script like this ..

[CODE]#!/bin/ksh

cat /tmp/table.out|while read -r table vbar1
do

then
select * from $table limit 10; > /tmp/1.out
done

[/CODE

Plz help ..But This is resulting in error like this

Code:

ERROR: 'select * from limit 1;'
error ^ found "LIMIT" (at char 16) expecting an identifier found a keyword


…read more
Source: FULL ARTICLE at The UNIX and Linux Forums

Need To Delete Lines Based On Search Criteria

By angshuman

Hi All,

I have following input file. I wish to retain those lines which match multiple search criteria. The search criteria is stored in a variable seperated from each other by comma(,).

HTML Code:


SEARCH_CRITERIA = "REJECT, DUPLICATE"

Input File:

ERROR,MYFILE_20130214_11387,9,37.75
REJECT,MYFILE_20130214_12486,1,20
DUPLICATE,MYFILE_20130214_12486,8,17.75
REJECT,MYFILE_20130214_14903,9,37.75
ERROR,MYFILE_20130214_17108,9,37.75
DUPLICATE,MYFILE_20130214_1811,0,0


My ouput file should look like below:

HTML Code:

REJECT,MYFILE_20130214_12486,1,20
DUPLICATE,MYFILE_20130214_12486,8,17.75
REJECT,MYFILE_20130214_14903,9,37.75
DUPLICATE,MYFILE_20130214_1811,0,0


Thanks & Regards
Angshuman

…read more
Source: FULL ARTICLE at The UNIX and Linux Forums

Grep a string in the log file

By ajothi

logfile=”/var/tmp.log”
output=$(grep “ERROR” $logfile)
if [ -n $output ]
then
echo “exceptions logged , please check /var/tmp.log for more details” | mail -s “exceptions logged , please check /var/tmp.log on for more details” $DL
else
echo “not found”
fi

Somehow its not working as expected, I am trying to grep the error string and send an email if the string “error” is present on the log file, could you please help in this?

Source: FULL ARTICLE at The UNIX and Linux Forums

Shell script- need help

By ajothi

logfile=”/var/tmp.log”
output=$(grep “ERROR” $logfile)
if [ -n $output ]
then
echo “exceptions logged , please check /var/tmp.log for more details” | mail -s “exceptions logged , please check /var/tmp.log on for more details” $DL
else
echo “not found”
fi

Somehow its not working as expected, I am trying to grep the error string and send an email if the string “error” is present on the log file, could you please help in this?

Source: FULL ARTICLE at The UNIX and Linux Forums

need help in Grep a string in the log file

By ajothi


logfile="/var/tmp.log"
output=$(grep "ERROR" $logfile)
if [ -n $output ]
then
echo "exceptions logged , please check /var/tmp.log for more details" |
mail -s "exceptions logged , please check /var/tmp.log on for more details" $DL
else
echo "not found"
fi


Somehow its not working as expected, I am trying to grep the error string and send an email if the string “error” is present on the log file, could you please help in this?

Source: FULL ARTICLE at The UNIX and Linux Forums

Genhtml problem with lcov

By ajay09c

Hi,

I am using lcov10.0-1 version. While doing make with target as follows

make -j17 ‘targetname’

am getting following errors. Its giving different errors different times.

==========================================================
genhtml: ERROR: cannot open /proj/ecoNH:0 for reading!
make[3]: *** [CMakeFiles/genhtml] Error 2
make[2]: *** [CMakeFiles/genhtml.dir/all] Error 2
make[1]: *** [CMakeFiles/unittest.dir/rule] Error 2
make: *** [unittest] Error 2

==========================================================
genhtml: ERROR: cannot open /home/mafting8internal8EqHelperILb0EE7CompareIbbEENS_15AssertionResultEPKcS6_RKT_RKT0_ for reading!
make[3]: *** [CMakeFiles/genhtml] Error 2
make[2]: *** [CMakeFiles/genhtml.dir/all] Error 2
make[1]: *** [CMakeFiles/unittest.dir/rule] Error 2
make: *** [unittest] Error 2
==========================================================
genhtml: ERROR: cannot open /proj/ecoderINS_4VoidEEC1Ev for reading!
make[3]: *** [CMakeFiles/genhtml] Error 2
make[2]: *** [CMakeFiles/genhtml.dir/all] Error 2
make[1]: *** [CMakeFiles/unittest.dir/rule] Error 2
make: *** [unittest] Error 2
==========================================================
genhtml: ERROR: cannot open /proj/eco:321,_ZNSt8multimapImSt4pairIKSsPP16MafNameValuePairESt4lessImESaIS0_IKmS5_EEE3endEv for reading!
make[3]: *** [CMakeFiles/genhtml] Error 2
make[2]: *** [CMakeFiles/genhtml.dir/all] Error 2
make[1]: *** [CMakeFiles/genhtml.dir/rule] Error 2
make: *** [genhtml] Error 2
==========================================================
genhtml: ERROR: cannot open /home/mafF:4 for reading!
make[3]: *** [CMakeFiles/genhtml] Error 2
make[2]: *** [CMakeFiles/genhtml.dir/all] Error 2
make[1]: *** [CMakeFiles/unittest.dir/rule] Error 2
make: *** [unittest] Error 2
==========================================================

Please help me on this.

Note: Am not getting any errors when I compiling without ‘-j’ option and also have all permission for directories.

Thanks in Advance.

Source: FULL ARTICLE at The UNIX and Linux Forums

Pkgchk error Solaris 10

By cjashu

Hi Guys,
I ran a package check command on my solaris 10 sparc system and it displayed most of the packages with errors:


pkgchk
ERROR: /boot/amd64/x86.miniroot-safe
modtime expected actual
file size expected actual
file cksum expected actual
ERROR: /boot/grub/menu.lst
modtime expected actual
file size expected actual
file cksum expected actual
ERROR: /boot/solaris/bootenv.rc
modtime expected actual
file size expected actual
file cksum expected actual
ERROR: /boot/solaris/devicedb/master
file size expected actual
file cksum expected actual


Is this normal or is there something wrong ? Please help.

Thanks

Source: FULL ARTICLE at The UNIX and Linux Forums

ERROR: `(' is not expected.

By Elvis

Hi All,

I have written a shell script which works all right on bash shell, but when it comes to execute it using ksh on AIX it gives the following error::(

bash$ /bin/ksh getShortInfo.sh
getShortInfo.sh[10]: syntax error at line 26 : `(‘ unexpected

Could you please indicate what is wrong? In addition, if you could indicate how can I make it portable on bash/ksh/csh would be really appreciated.

Please you can find below the guilty part of the script:

#!/bin/sh

COMMANDS=””
file_name=’systemInfo.txt’
OS_TYPE=`uname`

getCommandsSpecificOS(){
AIX_COMMANDS[0]=”hostname”

SunOS_COMMANDS[1]=”uname –a”
SunOS_COMMANDS[2]=”ulimit –a”

Linux_COMMANDS[0]=”hostname”
Linux_COMMANDS[3]=”cat /proc/cpuinfo”
Linux_COMMANDS[4]=”cat /proc/meminfo”

if [ $1 = “AIX” ]; then
COMMANDS=(“${AIX_COMMANDS[@]}”)
elif [ $1 = “SunOS” ]; then
COMMANDS=(“${SunOS_COMMANDS[@]}”)
elif [ $1 = “Linux” ]; then
COMMANDS=(“${Linux_COMMANDS[@]}”)

fi
}

###################################################################################################

getCommandsSpecificOS $OS_TYPE

Thanks in advance indeed,
Regards,
Elvis

Source: FULL ARTICLE at The UNIX and Linux Forums

Why execution is different from orginal bash registry$database?

By jediwannabe

Hi all,

here’s my script

Code:


#!/bin/ksh
if [ -z "$DB_CREATE_PATH" ]
then
export DB_CREATE_PATH=`pwd`
fi

echo
echo "********************--Menu--*****************************"
echo "*** "
echo "*** 1. Pre-Upgrade Steps "
echo "*** 7. Exit "

read a

if [ $a == 1 ]
then

echo "1 Pre-Upgrade Steps"
${ORACLE_HOME}/bin/sqlplus /nolog <<!EOF
set termout on
set echo on
set time on

connect / as SYSDBA;

column timecol new_value timestamp
column spool_extension new_value suffix
SELECT to_char(sysdate,'dd_Mon_yyyy_hhmi') timecol,'.log' spool_extension FROM
sys.dual;
column output new_value dbname
SELECT value || '_' output FROM v$parameter WHERE name = 'db_name';

--step 6 step 7 start
spool logs/tz_version_nls_char_&&dbname&&timestamp&&suffix
select TZ_VERSION from registry$database;
select value from NLS_DATABASE_PARAMETERS where parameter = 'NLS_NCHAR_CHARACTERSET';
spool off
--step 6 step 7 end

exit;
!EOF
fi


when I examine the output code it is as follow

Code:

09:30:41 SQL> select TZ_VERSION from registry;
select TZ_VERSION from registry
*
ERROR at line 1:
ORA-00942: table or view does not exist

09:30:41 SQL> select value from NLS_DATABASE_PARAMETERS where parameter = 'NLS_NCHAR_CHARACTERSET';

VALUE
-----------------------------------------------------------------------------------------------------------------------------
-------------------------
AL16UTF16

1 row selected.

09:30:41 SQL> spool off


can someone tell me how do I make sure that registry$database is queried instead of registry?

thanks

Source: FULL ARTICLE at The UNIX and Linux Forums

Error after first boot OEL5.8

By sohail Jafferi

Server Model
HP Proliant DL380P, Gen 8
Raid Controller= HP smart Array P420i
Operating system Installation OEl5.8
On first boot after OS installation

ERROR:
Red Hat nash Version 5.119.6 starting -300.10.1.el5uek)’
Mounting proc Filesystem
Reading all physical volume this may take a while
No volume groups FOUNDFS partition type 0x83
volume group “Volumegroup00” not foundk ro root=/dev/valgroup00/logvo100
unable to access resume device (/dev/VolGroup00/logVol01)
mount : could not find file system ‘/dev/root’40]
setuproot: moving /dev failed : no such file or directory
setuproot: error mounting /proc : no such file or directory
setuproot : error mounting /sys : no such file or directory
Switchroot: mount failed : no such file or directory
kernel panic – not syncing : Attempted to kill init!

kindly suggest me the suitable solution

Source: FULL ARTICLE at The UNIX and Linux Forums

Problem with XStringListToTextProperty

By kristinu

I am having a problem with this code giving me

Code:

xbuplot.c: In function ‘void xbuinit_(float*, float*)’:
xbuplot.c:213:63: error: invalid conversion from ‘const char**’ to ‘char**’ [-fpermissive]
In file included from xbuplot.c:2:0:
/usr/include/X11/Xutil.h:727:15: error: initializing argument 1 of ‘int XStringListToTextProperty(char**, int, XTextProperty*)’ [-fpermissive]
xbuplot.c:220:59: error: invalid conversion from ‘const char**’ to ‘char**’ [-fpermissive]
In file included from xbuplot.c:2:0:
/usr/include/X11/Xutil.h:727:15: error: initializing argument 1 of ‘int XStringListToTextProperty(char**, int, XTextProperty*)’ [-fpermissive]


Code:


const char* icon_name = "Xbuplot";
const char* window_name = "Xbuplot";

if (XStringListToTextProperty (&window_name, 1, &windowName ) == 0) {
(void) fprintf (stderr, "ERROR: structure allocation for windowName failed.n");
exit(-1);
}

if (XStringListToTextProperty (&icon_name, 1, &iconName ) == 0) {
(void) fprintf (stderr, "ERROR: structure allocation for iconName failed.n");
exit(-1);
}


Source: FULL ARTICLE at The UNIX and Linux Forums