10-12-2012
"Syntax Error sometimes due to corruption of variable value "
Hi ,
I have script as follows ,
#!/usr/bin/ksh -x
if [ `uname` = "Linux" ]
then
alias echo="echo -e"
fi
MAX_ENTRIES=1024
nb_of_entries=`echo "$list_of_entries" | wc -w`
# Set number of tables
eval nb_of_tables=\`expr `expr $nb_of_entries / $MAX_ENTRIES` + 1 \`
# Output the number of tables
echo $nb_of_tables
Here "list of entries" is list of PID's and we get the output as number of pids .
================
For this above part i get the following error ,
+ echo -e $' 1\n 2\n 3\n 4\n 5\n 6\n 7\n 8\n 9\n 10\n 11\n 12\n 13\n 14\n 15\n 16\n 17\n 18\n 59\n 66\n 67\n 68\n 69\n 70\n 233\n 234\n 235\n 236\n 239\n 241\n 328\n 329\n 330\n 331\n 332\n 333\n 334\n 544\n 596\n 597\n 598\n 599\n 600\n 626\n 629\n 657\n 691\n 1414\n 4674\n 4676\n 4677\n 4678\n 4718\n 4720\n 5060\n 5062\n 5094\n 5096\n 5119\n 5122\n 5134\n 5155\n 5184\n 5223\n 5242\n 5253\n 5257\n 5291\n 5329\n 5348\n 5366\n 5385\n 5396\n 5401\n 5416\n 5427\n 5439\n 5450\n 5461\n 5492\n 5513\n 5549\n 5550\n 5562\n 5564\n 5572\n 5577\n 5588\n 5660\n 5707\n 5770\n 5775\n 5776\n 5777\n 5779\n 5781\n 5783\n 5785\n 5883\n 5885\n 5886\n 5901\n 5904\n 5914\n 6046\n 6314\n 6316\n 6320\n 6332\n 6334\n 6336\n 6339\n 6347\n 6349\n 6351\n 6353\n 6362\n 6367\n 6399\n 6402\n 6404\n 6406\n 6408\n 6410\n 6412\n 6414\n 6416\n 6418\n 6420\n 6428\n 6431\n 6557\n 6568\n 6847\n 6850\n 6856\n 7354\n 7378\n 7405\n 7426\n 7448\n 7463\n 7472\n 7483\n 7541\n 7683\n 8119\n 8121\n 8323\n 8325\n 8326\n 8327\n15699\n21205\n21236\n25117'
+ wc -w
+ nb_of_entries=' 156'
+ expr 1 6 / 1024
expr: syntax error
Here 156 is replced with 1 6 which leads to syntax error . Please help me in finding what is making this corruption of variable value ?
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I am trying to run the script bellow but its given me "syntax error at line 20 :'done' unexpected." error message"
can someone check to see if the script is ok? and correct me pls.
Today is my first day with scripting.
Gurus should pls help out
#!/bin/ksh
# Purpose: Check to see if file... (3 Replies)
Discussion started by: ibroxy
3 Replies
2. Shell Programming and Scripting
Hi all,
Iīve already searched the forum but canīt find what i am doing wrong.
I am trying to compare two variables using ksh under red hat. The error I get is:
-ksh: .: MDA=`md5sum /tmp/ftp_dir_after_transfer | cut -d' ' -f1 `
MDB=`md5sum /tmp/ftp_dir_before_transfer | cut -d' ' -f1 `... (3 Replies)
Discussion started by: old_mike
3 Replies
3. Forum Support Area for Unregistered Users & Account Problems
Hi all,
I am trying to register but it seems my IP address is being seen or black listed as a spam address.
I get the following message:
"Registration denied. Sorry, The UNIX and Linux Forums runs an active policy of not allowing spammers. Please contact us via by posting in this forum if... (0 Replies)
Discussion started by: codenjanod
0 Replies
4. Shell Programming and Scripting
I am running a program written in perl script and it is stopped with "Out of memory!" error. This is very strange because at the time then the program is aborted, it only used 4GB RAM and there are still 30GB free physical memory left in the system. I check the perl script and found the program... (3 Replies)
Discussion started by: lilili07
3 Replies
5. Shell Programming and Scripting
Hello forum,
I hope my problem is easy to solve for someone in here!
My main task is to copy a large amount of imap-accounts from one server to another. There is a tool (Perl) called imapsync which does the job exellent. Unfortunately I'm only able to run it on one account at a time.
After... (3 Replies)
Discussion started by: primaxx
3 Replies
6. Shell Programming and Scripting
the below code will search attr string inside makefile under the modelno on given path.
echo "Enter model no for searching string inside makefile"
read inputs2
#find /pools/home_unix/sapte/work/models/model/$inputs2 -name "makefile" | xargs grep "attr" \;
#;;I am getting below error.... (7 Replies)
Discussion started by: lathigara
7 Replies
7. Homework & Coursework Questions
Hi All,
As per my knowledge in unix, my code looks fine. But still I am getting error (expr:syntax error). Please help me to resolve this error.
Script :
PRE_LBNO=0
PRE_DATE=0
TOT_PAY=0
TOT_REM=0
TOTAL=1
for Record_Type in `cut -c 1 Inputt.dat`
do
if ;
then
CURR_LBNO=` cut -c... (6 Replies)
Discussion started by: lathanandhini
6 Replies
8. Shell Programming and Scripting
Hi All,
Please hav a look at the below peice of script and let me know if there are any syntax errors.
i found that the below peice of Script is causing issue. when i use SFTP its working fine, but there is a demand to use FTP only. please find below code and explain if anything is wrong... (1 Reply)
Discussion started by: mahi_mayu069
1 Replies
9. Ubuntu
Does anyone know what is solution for this error ?tar: Exiting with failure status due to previous errors from last 3 days I am trying to take backup of home/user directory getting again and again same error please anyone give me solution (8 Replies)
Discussion started by: Akshay Hegde
8 Replies
10. BSD
#!/bin/bash
#--------------------------------------------------------
# Setup prompt
# Author Zeeshan Mirza
# Data: 06-08-2017
#--------------------------------------------------------
if
then
. ./.profile_custom_pre
fi
umask 022
set -o vi
export EDITOR=vi
export VISUAL=vi... (3 Replies)
Discussion started by: getzeeshan
3 Replies
EXPR(1) General Commands Manual EXPR(1)
NAME
expr - evaluate arguments as an expression
SYNOPSIS
expr arg ...
DESCRIPTION
The arguments are taken as an expression. After evaluation, the result is written on the standard output. Each token of the expression is
a separate argument.
The operators and keywords are listed below. The list is in order of increasing precedence, with equal precedence operators grouped.
expr | expr
yields the first expr if it is neither null nor `0', otherwise yields the second expr.
expr & expr
yields the first expr if neither expr is null or `0', otherwise yields `0'.
expr relop expr
where relop is one of < <= = != >= >, yields `1' if the indicated comparison is true, `0' if false. The comparison is numeric if
both expr are integers, otherwise lexicographic.
expr + expr
expr - expr
addition or subtraction of the arguments.
expr * expr
expr / expr
expr % expr
multiplication, division, or remainder of the arguments.
expr : expr
The matching operator compares the string first argument with the regular expression second argument; regular expression syntax is
the same as that of ed(1). The (...) pattern symbols can be used to select a portion of the first argument. Otherwise, the
matching operator yields the number of characters matched (`0' on failure).
( expr )
parentheses for grouping.
Examples:
To add 1 to the Shell variable a:
a=`expr $a + 1`
To find the filename part (least significant part) of the pathname stored in variable a, which may or may not contain `/':
expr $a : '.*/(.*)' '|' $a
Note the quoted Shell metacharacters.
SEE ALSO
ed(1), sh(1), test(1)
DIAGNOSTICS
Expr returns the following exit codes:
0 if the expression is neither null nor `0',
1 if the expression is null or `0',
2 for invalid expressions.
EXPR(1)