Problem with -s option in IF


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Problem with -s option in IF
# 1  
Old 11-04-2013
Problem with -s option in IF

Hello Guys ,

I am trying to run below in one of my script but unable to get it succeed .
Can anyone help me on this?

I am using HP-UX.

Code:
if [ -s ${MGCA_RESULTS_PATH} && -s ${MGCA_TMP_LOG} ]
then
    write_log " Both files are present . Mail will be send to respective teams."
    EMAIL_SUBJECT="MGCA - File Extraction Process COMPLETED"

error:-
Code:
+ [ -s
MGCA_daily_extraction.sh[163]: test: ] missing


I have tried all upside - down , but could not figure it out.

Thanks,
Himanshu Sood

Last edited by vbe; 11-05-2013 at 09:53 AM.. Reason: code tags, rm fancy colour stuff
# 2  
Old 11-04-2013
Code:
if [[ -s ${MGCA_RESULTS_PATH} && -s ${MGCA_TMP_LOG} ]]

# 3  
Old 11-04-2013
Or
Code:
if [ -s ${MGCA_RESULTS_PATH} -a -s ${MGCA_TMP_LOG} ]

# 4  
Old 11-05-2013
This still do not works . getting below error :
Code:
[195]: syntax error at line 208 : `-a' unexpected
Kindly help.

Thanks,
Himanshu Sood

Last edited by vbe; 11-05-2013 at 09:49 AM.. Reason: code tags please, for data and code
# 5  
Old 11-05-2013
Quote:
Originally Posted by HIMANSHU SOOD
Kindly help.
Tricky, when we have no idea what's on line 208...
# 6  
Old 11-05-2013
Its pointing to same line that i have asked before .

But somehow it worked fine for me using test command as below :-
Code:
if test -f ${MGCA_RESULTS_FILE} && test -f ${MGCA_TMP_LOG}¨

Thanks guys for ur suggestions.

Thanks,
Himanshu Sood

Last edited by vbe; 11-05-2013 at 09:50 AM.. Reason: code tags!
# 7  
Old 11-05-2013
Joining CarloM here:
Code:
ant:/home/vbe/test/test $ uname -sr
HP-UX B.11.11
ant:/home/vbe/test/test $ ll
total 8
drwxr-xr-x   2 vbe        bin             96 Nov  5 15:07 .
drwxr-xr-x   3 vbe        sys           1024 Nov  5 15:04 ..
-rw-r--r--   1 vbe        bin              5 Nov  5 15:11 aa
-rw-r--r--   1 vbe        bin              5 Nov  5 15:11 bb
-rwxrwxr-x   1 vbe        bin            107 Nov  5 15:19 test01
ant:/home/vbe/test/test $ cat test01
if [  -s $1 -a  -s $2  ] # if [  -s ${1} -a  -s ${2} ] works also!!
then
    echo OK
else 
    echo KO
fi

ant:/home/vbe/test/test $ test01 aa bb
OK
ant:/home/vbe/test/test $

...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Is "stat: illegal option -- -" an issue with hyphenated filename or flag problem?

Hi. I'm trying to install VMWare Workstation to run a virtual machine on my Mac OS, but running the bundle from bash(xterm) sh VMware-workstation-Full-11.0.0-2305329.x86_64.bundle (as suggested in install guide) comes up with error:stat: illegal option -- - usage: stat Digging... (5 Replies)
Discussion started by: defeated
5 Replies

2. Shell Programming and Scripting

Problem in Using fgrep Command with pattern file option

Hi, i am using fgrep command with following syntax fgrep -v -f pattern_file_name file file contains few line and have the pattern which i am giving in pattern file. My Problem is : its is not giving any output. while i am using fgrep -f pattern_file_name file it is showing all... (4 Replies)
Discussion started by: emresearch
4 Replies

3. Shell Programming and Scripting

Problem with -c option in Mailx command

Hi, I am using mailx command in shell script. When i put -c option for CC , i get error message as "Unknown flag: -c" . I checked manual of mailx command and found that ~c to be used but after using ~c also it is not working. My shell is Korn. Kindly let me know what i have to do . Thanks (9 Replies)
Discussion started by: krishna_gnv
9 Replies

4. IP Networking

Problem when I Open my WireShark - No Interfaces Option available

Hi gurus of unix, I haved installed my openSolaris in a HP530, Recently I use the following command beadm destry opensolaris1 beadm destry opensolaris2 After That I reboot my Laptop. Well when I go to my work I try to open my wireshark tool, but the option in GUI interface does not appear!!!... (2 Replies)
Discussion started by: andresguillen
2 Replies

5. UNIX for Advanced & Expert Users

Problem with useradd, -p option in Solaris 10

Good day all. I'm trying to add a user with useradd and the -p option to assign a project name, but the result is that the user is created with an error message: "UX: useradd: user.root name should be all lower case or numeric." The command: useradd -d /export/home/tester -g rtpgrp -G... (2 Replies)
Discussion started by: BRH
2 Replies

6. Shell Programming and Scripting

Problem in file usage option

Hi, I have a dout in -u option in ls command. If we give ls -lt command it will dispaly the last modfied time. If we give ls -lu command it will display the last usage time of the file. My doubt here is Please refer the below commands. /appldata/rsc/dm/RejectData$ls -lt... (6 Replies)
Discussion started by: puni
6 Replies

7. Shell Programming and Scripting

recently introduced to the newer option for find...does an older option exist?

To find all the files in your home directory that have been edited in some way since the last tar file, use this command: find . -newer backup.tar.gz Is anyone familiar with an older solution? looking to identify files older then 15mins across several directories. thanks, manny (2 Replies)
Discussion started by: mr_manny
2 Replies

8. UNIX for Advanced & Expert Users

Problem with Carbon copy (CC) option in mailx command

Hi, I have problems with the cc option in mailx command. Just went through some of the similar threads but none provides a satisfactory explanation. I have a script using the mailx command in the following way: (echo `cat mailsub.txt` ; uuencode attachment.csv attachment.csv) | mailx -s... (2 Replies)
Discussion started by: SmithaN
2 Replies

9. Shell Programming and Scripting

option followed by : taking next option if argument missing with getopts

Hi all, I am parsing command line options using getopts. The problem is that mandatory argument options following ":" is taking next option as argument if it is not followed by any argument. Below is the script: while getopts :hd:t:s:l:p:f: opt do case "$opt" in -h|-\?)... (2 Replies)
Discussion started by: gurukottur
2 Replies

10. UNIX for Dummies Questions & Answers

problem in ssh with -i option

Hi All, I want to ssh to a remote terminal i did the following steps 1. On the client run the following commands: 2. $ mkdir -p $HOME/.ssh 3. $ chmod 0700 $HOME/.ssh 4. $ ssh-keygen -t dsa -f $HOME/.ssh/id_dsa -P '' and then tried the following $ ssh -i $HOME/.ssh/id_dsa server ... (1 Reply)
Discussion started by: gauri
1 Replies
Login or Register to Ask a Question