Hi,
I have a file whose first line has some name followed by the timestamp and the sequence number. The last 3 digits of that line is seq number. If I get seq num other than 001, 004, 007 then I should generate an error saying, incorrect seq number else success. I am trying to run the following script but it is not giving me the exact result. It is working if I give -eq but with -ne it is not working. Can anyone help me out plz? sys_nam and timestamp I want for other purpose.
(And if you do use awk, put in an exit command so that it doesn't read the whole file for nothing.)
See below for the _substr function.
Quote:
if [[ $in_seq_num -ne "001" || $in_seq_num -ne "004" || $in_seq_num -ne "007" ]];
then
notice_val="103"
notice_desc="Seq number not as exptected"
else
notice_val="000"
notice_desc="Success"
fi
Don't use the non-portable [[...]] syntax, and remember that numbers with leading zeroes are interpreted as octal number.
The best method in this instance is case:
Code:
case $in_seq_num in
001|004|007)
notice_val="000"
notice_desc="Success"
;;
*)
notice_val="103"
notice_desc="Seq number not as expected"
;;
esac
The _substr function:
There are two different _substr functions, the first for ksh93 or bash (version 2 or later), the second for any POSIX shell:
Code:
_substr() {
if [ $2 -lt 0 ]
then
_SUBSTR=${1:$2:${3:-${#1}}}
else
_SUBSTR=${1:$(($2 - 1)):${3:-${#1}}}
fi
}
Code:
_substr()
{
_SUBSTR=
## store the parameters
ss_str=$1
ss_first=$2
ss_length=${3:-${#ss_str}}
## return an error if the first character wanted is beyond end of string
if [ $ss_first -gt ${#ss_str} ]
then
return 1
fi
if [ $ss_first -gt 1 ]
then
## build a string of question marks to use as a wildcard pattern
_repeat "?" $(( $ss_first - 1 ))
## remove the beginning of string
ss_str=${ss_str#$_REPEAT}
elif [ ${ss_first} -lt 0 ] ## ${#ss_str} ]
then
## count from end of string
_repeat "?" ${ss_first#-}
## remove the beginning
ss_str=${ss_str#${ss_str%$_REPEAT}}
fi
## ss_str now begins at the point we want to start extracting
## print the desired number of characters
if [ ${#ss_str} -gt $ss_length ]
then
_repeat "${ss_wild:-??}" $ss_length
ss_wild=$_REPEAT
_SUBSTR=${ss_str%${ss_str#$ss_wild}}
else
_SUBSTR=${ss_str}
fi
}
Hello,
I have X4500 running Solaris 10. I can access it through CLI but I cannot see the GUI. When I reboot it, the GUI works till all the files are loaded (ie., the initial boot sequence) and it prompts me to enter username and password and there it ends. The screen just has a blinking cursor... (4 Replies)
Dear all,
I am totally despaired and puzzled.
Using Filezilla under Windows under the same network as our Linux servers is working. Using FTP command-line client under any of our Linux debian servers is not working ! I tried with different FTP servers -> same problem !
All commands are... (12 Replies)
Hello,
I am facing a very strange problem when I run my script manuallu ./Fetchcode which is using to connect with MKS integrity from linux end it workks fine but when I run it from cron it doesn't work.Can someone help me
1) How could I check my script when it is running from cron like... (3 Replies)
Hi, This is a strange issue: We have an sftp server. Users can ssh to it from internal LAN without any issue, but they can not ssh to it externally via firewall. Here is what I got:
OS is Solaris 9. No hosts.allow and hosts.deny files.
Please help. Thank you in advance! (7 Replies)
Help. My script is working fine when executed manually but the cron seems not to catch up the command when registered.
The script is as follow:
#!/bin/sh
for file in file_1.txt file_2.txt file_3.txt
do
awk '{ print "0" }' $file > tmp.tmp
mv tmp.tmp $file
done
And the cron... (2 Replies)
Hi Team
we have created a DNS server at RHEL6.2 environment in 10.20.203.x/24 network.
Everything is going well on linux client as nslookup, ping by host etc in entire subnet. We are getting problem in windows client as nslookup working as well but not ping. all the firewall is disabled and... (5 Replies)
I am trying to automate a script where I need to use pbrun /bin/su but for some reason it is not passing thru the pbrun as my code below.
. ~/.bash_profile
pbrun /bin/su - content
c h 1
hpsvn up file path
I am executing this from an external .sh file that is pointing to this scripts file... (14 Replies)
Hi,
Can anyone help me on my PHP cron not working, but when i do the manual it work.
# manual run working
/usr/local/bin/php /root/dev/test.php
# crontab not working
55 8 * * * /usr/local/bin/php /root/dev/test.php
Thank in advances
Regards,
FSPalero
Please use CODE tags as... (2 Replies)
Hello, Newbie here,
I have a perfectly well working web service call I can issue from chrome (PC Windows 10) and get the results I want (a dimmer being turned on in Fibaro Home Center 2 at level 40)
I am not allowed to post urls but the below works with http and :// and... (3 Replies)
Hi Team,
I have written the shell script which returns the result of the disk space filesystems which has crossed the threshold limit in HTML Format. Below mentioned is the script which worked perfectly on QA system.
df -h | awk -v host=`hostname` '
BEGIN {
print "<table border="4"... (13 Replies)