Sponsored Content
Top Forums UNIX for Advanced & Expert Users Test -e not working as expected (by me) Post 302938002 by rbatte1 on Wednesday 11th of March 2015 09:36:52 AM
Old 03-11-2015
Consider testing for a link instead:-
Code:
$ ls -l a b
ls: cannot access a: No such file or directory
lrwxrwxrwx 1 RBATTE1 TS 1 Mar 11 13:32 b -> a

$ if [ -L b ]
> then
>   echo hit
> else
>   echo miss
> fi
hit

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

test:argument expected

Hi all, I am getting "test:argument expected" error in the following script LOGDIR=$XXAR_TOP/log PROGRAM_NAME=XXAR_GPS_LBFDMSGEN .. .. .. Check_Errors() { sqllogfile=$1 cd ${LOGDIR} countfile=${LOGDIR}/${PROGRAM_NAME}.tmp echo "countfile is " $countfile >> $LOGFILE echo... (4 Replies)
Discussion started by: rrs
4 Replies

2. Shell Programming and Scripting

test: argument expected

Can someone help me with a very simple query I have the following script: #!/bin/sh VAR1="" if then VAR1="Message" fi echo $VAR1 put when i run it i get the following error test_job.sh: test: argument expected (5 Replies)
Discussion started by: andy202
5 Replies

3. Shell Programming and Scripting

test: argument expected

I'm newbie to coding script so i found test: argument expected when i run it. please help me a=`df -k |awk '{print $5 }'|egrep "(100%|%)"|cut -d"%" -f1|tail -1` if then df -k|egrep "(100%|%)"|awk '{print $1,$5,$6}' else echo "No disk capacity more than 80%" fi thk in advance (7 Replies)
Discussion started by: unitipon
7 Replies

4. Shell Programming and Scripting

test: argument expected

+ test.sh: test: argument expected #!/bin/bash if then echo thennnn else echo elseeee fi why does it show this error? Clearly from debug mode, the argument is passed. I also tried if Run on Solaris 9. Thanks (10 Replies)
Discussion started by: lalelle
10 Replies

5. Shell Programming and Scripting

crontab test argument expected

Hello folks, I've got this script which runs perfectly when i run it manually. But when i am running it from a crontab i am getting an error saying test argument expected. The line from where it is coming is something like this: if then do something fi Any idea why? (2 Replies)
Discussion started by: King Nothing
2 Replies

6. Shell Programming and Scripting

Test: argument expected.

Hi, Since i am new to Unix and on suggestion on some smart guys on unix... i have decide to learn more deeply on Unix...so i was kind of playing with if statements and found this error... though i tried to correct is for hours now i couldnt find whats wrong in my loop. if then ... (4 Replies)
Discussion started by: bhagya2340
4 Replies

7. Shell Programming and Scripting

test: argument expected

# to search a file if it exists and whether its readable or not # if yes print its first 5 lines echo enter the filename to be searched read fname if #-d $fname then echo file doesn exists elif then echo its a directory elif then cat $fname else echo its not readable fi # end of... (9 Replies)
Discussion started by: gotam
9 Replies

8. Shell Programming and Scripting

error : test: argument expected

Hello all, I am trying to figure out why i am getting an error while executing the script...altought it seems like its work...but still get the test arguement error...any help would be appericiate...this script basically connects to any oracle db ( just have to pass db name to it)... (4 Replies)
Discussion started by: abdul.irfan2
4 Replies

9. Shell Programming and Scripting

Error- test: argument expected

check_build_info_table() { if then export build_info_table=`sqlplus -s sna/dbmanager <<! set pagesize 0 heading off feedback off SELECT DISTINCT TABLE_NAME FROM ALL_TABLES WHERE OWNER = 'XYZ' AND TABLE_NAME = 'MY_TABLE'; exit !` ... (3 Replies)
Discussion started by: ambarginni
3 Replies

10. Shell Programming and Scripting

Test: argument expected

The following example prompts are passed into the shell script. $1 = /tmp/dir/ $2 = varies (test.txt, test1.txt, test2.txt...) $3 = test_YYYYMMDD.txt --------------------------------------------------------------------------- #!/bin/sh cd $1 if ; then if ; then ... (3 Replies)
Discussion started by: smkremer
3 Replies
FunctionalTestCase(3pm) 				  LogReport's Lire Documentation				   FunctionalTestCase(3pm)

NAME
Lire::Test::FunctionalTestCase - Base class for writing functional unit tests SYNOPSIS
use base qw/ Lire::Test::FunctionalTestCase/; DESCRIPTION
This is a Test::Unit::TestCase subclass which can be used to make it easier to write functional tests. WHAT ARE FUNCTIONAL TESTS Unlike unit tests that test the semantics of the API and document the internals assumptions, functional tests are tests that tests the 'functionality' of the overall software. They kind of document the expected functionality of the software. Lire::Test::FunctionalTestCase In Lire, the "expected functionality" is exercised by running commands, so this module provides convenient methods to run Lire commands and tests their expected output. It also setup a mock sendmail which can be used to analyze the email that the Lire system should send. Some of Lire functionality cannot be tested anymore simply by running command (for example the Curses::UI based user interface cannot be tested that way but throught the use of Lire::Test::CursesUIDriver). For these kind of tests, this base class will set up a new Lire::Config and Lire::PluginManager instance in the set_up method. Tests that requires these functionality can simply call Lire::Config->init() and Lire::PluginManager->instance()->register_default_converters() without fear of messing the test environement. homedir() Returns the directory which will be assigned to ENV{'HOME'} when commands are run. This directory is cleaned up after every test. rundir() Returns the directory which will be the working directory when the commands are run. This directory is cleaned up after every test. config_spec() Returns the Lire::Config::TypeSpec object which will be used at runtime by the functional tests. It can be used to setup configuration files for the test. locale( [new_locale] ) Changes the locale under which the functional test is going to be run. By default, all tests are run under the 'C' locale ignoring all user's environment variables. Returns the previous locale set. lire_run( $shell_cmd ) This method runs the command $shell_cmd through the shell and returns a Lire::Test::CommandResult object which can be used to run tests on this command. The Lire environment will be set up before invoking the shell. sent_mail() Returns in an array reference the message that were sent out during the test. The element of this array are hash reference containing two keys: recipients An array reference containing the recipients as passed on the command line to sendmail. message The email which was sent. This is the complete text of the email. This is what was passed to sendmail via STDIN. create_test_file( $filename, [$content] ) Create a file $filename with the content $content. This file will be removed after the test is run during the tear_down() method. An empty file will be created if the $content parameter is omitted. install_xml_spec( $spec_type, $superservice, $file ) Install the XML specification in $file of base schema $superservice. The $spec_type parameter specify where the file will be installed: site_filter The file will be installed as a filter specification in the system directory. site_report The file will be installed as a report specification in the system directory. site_schema The file will be installed as a schema specification in the system directory. filter The file will be installed as a filter specification in the HOME directory. report The file will be installed as a report specification in the HOME directory. schema The file will be installed as a schema specification in the HOME directory. These files will be removed after the test. create_test_cfg_file( $name ) Returns a Lire::Config::ConfigFile object initialized with the appropriate config specification. This configuration file will be created under $HOME/.lire/config/$name.xml when lire_run() will be used. It can be use to set config option which will be used when the command is run: my $cfg = $self->create_test_cfg_file( "test" ); $cfg->global->get( "lr_from" )->set( "flacoste@logreport.org" ); If a configuration file $name was already created, it returns the associated ConfigFile object. Note that if you want these configurations variable to have effect when running test in-process ( not via lire_run() ), you have to call save() on the object before calling Lire::Config->init(). Otherwise, you better set the configuration option directly using the Lire::Config API. SEE ALSO
Test::Unit::TestCase(3pm) VERSION
$Id: FunctionalTestCase.pm,v 1.27 2006/07/23 13:16:31 vanbaal Exp $ AUTHOR
Francis J. Lacoste <flacoste@logreport.org> COPYRIGHT
Copyright (C) 2003 Stichting LogReport Foundation LogReport@LogReport.org This file is part of Lire. Lire is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program (see COPYING); if not, check with http://www.gnu.org/copyleft/gpl.html. Lire 2.1.1 2006-07-23 FunctionalTestCase(3pm)
All times are GMT -4. The time now is 01:25 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy