Help with error "por: 0403-012 A test command parameter is not valid."


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help with error "por: 0403-012 A test command parameter is not valid."
# 1  
Old 04-17-2013
Wrench Help with error "por: 0403-012 A test command parameter is not valid."

Hi, im asking for help with the next script:

Code:
echo ^[[32m  Mails Pending ^[[37m
VAR1=`query1.sh`

if [ $VAR1 -ge 200 ];
  then
     if [ $VAR1 -ge 300 ]
      then
         printf "\033[01;31m%s\033[00m\n" "$VAR1"
      else
         printf "\033[01;33m%s\033[00m\n" "$VAR1"
      fi
   else
         printf "\033[01;32m%s\033[00m\n" "$VAR1"
fi

echo " "

  sleep 30
  clear
done;

query1.sh:

Code:
export TERM=vt100
export ORACLE_TERM=at386
export ORACLE_HOME=/home_oracle8i/app/oracle/product/8.1.7
export ORACLE_BASE=/home_oracle8i/app/oracle
export DBVISIT_HOME=/usr/local/dbvisit

PATH=/home_oracle8i/app/oracle/product/8.1.7/bin:/usr/ccs/bin:/usr/bin:/etc:/usr/sbin:/usr/ucb:$HOME
/bin:/usr/bin/X11:/sbin:$DBVISIT_HOME:.
export PATH
export ORACLE_SID=ORAB817
export DISPLAY=192.9.200.121:0.0
export NLS_LANG=AMERICAN_AMERICA.WE8ISO8859P1
export ORA_ENCRYPT_LOGIN=TRUE
set umask=022
sqlplus -s " / as sysdba " @query1.sql

query1.sql:

Code:
set serveroutput on
set feedback off
set head off


SELECT   'MAILS PENDING  :  ' || COUNT ( * )   "Correo Por Enviar" FRO
M   SCHEMA.CSIC_MAILS_fOR_SEND@VIRT.DB.TGU.COM  WHERE   estado = 0;
 
 

 
exit;

When i execute the script it returns what i want, but before that it always gives me the error "j.sh[224]: por: 0403-012 A test command parameter is not valid."
# 2  
Old 04-17-2013
I noticed that you are selecting string: 'MAILS PENDING : ' and concatenating with count(*), this will result in having an alphanumeric value in variable: VAR1:
Code:
SELECT   'MAILS PENDING  :  ' || COUNT ( * )   "Correo Por Enviar" FROM
SCHEMA.CSIC_MAILS_fOR_SEND@VIRT.DB.TGU.COM  WHERE   estado = 0;

So if you try to do a numeric comparison: if [ $VAR1 -ge 200 ] it will fail because you have alphanumeric value in this variable.

I suggest you to modify your query to get just the record count:
Code:
SELECT COUNT(*) FROM
SCHEMA.CSIC_MAILS_fOR_SEND@VIRT.DB.TGU.COM  WHERE estado = 0;

# 3  
Old 04-17-2013
Wrench

Quote:
Originally Posted by Yoda
I noticed that you are selecting string: 'MAILS PENDING : ' and concatenating with count(*), this will result in having an alphanumeric value in variable: VAR1:
Code:
SELECT   'MAILS PENDING  :  ' || COUNT ( * )   "Correo Por Enviar" FROM
SCHEMA.CSIC_MAILS_fOR_SEND@VIRT.DB.TGU.COM  WHERE   estado = 0;

So if you try to do a numeric comparison: if [ $VAR1 -ge 200 ] it will fail because you have alphanumeric value in this variable.

I suggest you to modify your query to get just the record count:
Code:
SELECT COUNT(*) FROM
SCHEMA.CSIC_MAILS_fOR_SEND@VIRT.DB.TGU.COM  WHERE estado = 0;

Well it worked, thank you so much Yoda. now... i have another question... my code is now like this:

Code:
echo ^[[32m  MAILS PENDING HN ^[[37m
VAR1=`query1.sh`
DISP1="Amount of mails pending  :"$VAR1
if [ $VAR1 -ge 200 ];
  then
     if [ $VAR1 -ge 300 ]
      then
         printf "\033[01;31m%s\033[00m\n" "$VAR1"
      else
         printf "\033[01;33m%s\033[00m\n" "$VAR1"
      fi
   else
         printf "\033[01;32m%s\033[00m" "$DISP1" #<---- i created this variable for testing but the result is the same
fi

  sleep 30
  clear
done;

and the display goes like this:

"Amount of mails pending :
41 "

Yes... they are displayed in diferent lines and i would like to make them appera in the same line.... help plz.

I already removed \n and it didnt worked....
# 4  
Old 04-17-2013
Put variable VAR1 inside double quotes:
Code:
DISP1="Amount of mails pending  : $VAR1"

# 5  
Old 04-17-2013
Quote:
Originally Posted by Yoda
Put variable VAR1 inside double quotes:
Code:
DISP1="Amount of mails pending  : $VAR1"

Sorry, same result...

"Amount of mails pending :
16 "
# 6  
Old 04-17-2013
Replace following lines:
Code:
set serveroutput on
set feedback off
set head off

with below line:
Code:
set echo off head off feed off pagesize 0 trimspool on linesize 1000

in your file: query1.sql
This User Gave Thanks to Yoda For This Post:
# 7  
Old 04-17-2013
Wrench One more thing...plz

Quote:
Originally Posted by Yoda
Replace following lines:
Code:
set serveroutput on
set feedback off
set head off

with below line:
Code:
set echo off head off feed off pagesize 0 trimspool on linesize 1000

in your file: query1.sql
Well, thanks again... it worked....

"Amount of mails pending : 68"

Is there anything that can be done with the considerables spaces between the colon ":" and my query result "68" ?

Thanks in advance...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

2. UNIX for Dummies Questions & Answers

What is the significance of sh -s in ssh -qtt ${user}@${host} "sh -s "${version}"" < test.sh?

Please can you help me understand the significance of providing arguments under sh -s in > ssh -qtt ${user}@${host} "sh -s "${version}"" < test.sh (4 Replies)
Discussion started by: Sree10
4 Replies

3. Shell Programming and Scripting

A test command parameter is not valid, when special characters are tried to match

Hi I have a scenario where hyphen(-) from file should be ignored I used the following code if && ; then if ; then pow=$LINE echo $pow > history.txt flag=1 fi fi I get the following output ./valid.sh: -: 0403-012 A test... (7 Replies)
Discussion started by: Priya Amaresh
7 Replies

4. Shell Programming and Scripting

Error passing parameter in "sub" command in awk

I have to replace the pattern found in one file in another file with null/empty "" if found on the fields 3 or 4 ONLY File 1 ==== 10604747|Mxdef|9999|9999|9999|2012-03-04 00:00:59 10604747|Mcdef|8888|9999|8888|2012-03-04 00:00:59 . . . File 2 ==== 9999 8888 . . . Expected... (7 Replies)
Discussion started by: machomaddy
7 Replies

5. Shell Programming and Scripting

if condition error: test: 0403-004 Specify a parameter with this command

Hi all, I would like to ask if there's something wrong with my if - else condition, i couldn't run the script perfectly due to the error in my if - else condition stating that "test: 0403-004 Specify a parameter with this command." below is the snippet of my script if && && ] then echo... (5 Replies)
Discussion started by: jihmantiquilla
5 Replies

6. Shell Programming and Scripting

A test command parameter is not valid

Hello, Getting error "A test command parameter is not valid" when trying to run the code below under /sbin/sh AA = "12:00" CHK=$(date +"%H:%M") if then print "Yes" fi Getting 2 errors: 1) "AA: not found" 2) "Specify a parameter with this command" Thanks, IS Please... (5 Replies)
Discussion started by: schureki
5 Replies

7. UNIX for Dummies Questions & Answers

Unix "look" Command "File too large" Error Message

I am trying to find lines in a text file larger than 3 Gb that start with a given string. My command looks like this: $ look "string" "/home/patrick/filename.txt" However, this gives me the following message: "look: /home/patrick/filename.txt: File too large" So, I have two... (14 Replies)
Discussion started by: shishong
14 Replies

8. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

9. Shell Programming and Scripting

grep "\012$" problem

Hi, I am trying to weed out DOS '^M' new-line characters from a file which I copied from windows inside my Linux box, using this following script. But it seems this script is not working properly if I have made a check 'xargs grep -l "\012$"'. Here, I am trying to filter only the files which... (4 Replies)
Discussion started by: royalibrahim
4 Replies

10. Shell Programming and Scripting

Help regarding Error message: A test command parameter is not valid

Hi I am getting few messages when trying to run my script from the following lines in the script if test then // SomeCode fi The messages are as follows: testing.sh: OBLIGOR_GROUP_ID: 0403-012 A test command parameter is not valid. testing.sh:... (5 Replies)
Discussion started by: skyineyes
5 Replies
Login or Register to Ask a Question