I ran into the following and still do not understand entirely the rationale behind this. If someone could explain why things are as they are I'd be thankful.
The following was tested on AIX 7.1 with ksh88, but i suspect that to be ubiquitous. In an installation routine i had to create a set of symbolic links. Because they might already exist i used test -e filename to test it:
This didn't work as expected because test returned 0 only if the link AND its target existed. If only the link exists but not the file referenced by it test will return 1.
A "file that exists" is IMHO covered by a link, even if this link points to a file which doesn't. I can stat() this file and do many other operations on it which can be done with a file.
I do understand that i can use "-L", which tests for a link but i would like to understand the rationale behind the behavior. Or is the POSIX documentation inconsistent here?
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)
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)
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)
+
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)
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)
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)
# 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)
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)
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)
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
LEARN ABOUT DEBIAN
shelltest
SHELLTEST(1) version 1.2.1 SHELLTEST(1)NAME
shelltestrunner - test command-line programs or arbitrary shell commands
SYNOPSIS
shelltest [options] {testfiles|testdirs}
DESCRIPTION
shelltestrunner tests command-line programs (or arbitrary shell commands). It reads simple declarative tests specifying a command, some
input, and the expected output, and can run them run in parallel, selectively, with a timeout, in color, and/or with differences high-
lighted.
OPTIONS -a, --all
Show all failure output, even if large
-c, --color
Show colored output if your terminal supports it
-d, --diff
Show failures in diff format
-p, --precise
Show failure output precisely (good for whitespace)
-x STR, --exclude=STR
Exclude test files whose path contains STR
--execdir
Run tests from within the test file's directory. Test commands normally run within your current directory; --execdir makes them run
within the directory where they are defined, instead.
--extension=EXT
Filename suffix of test files (default: .test)
-w, --with=EXECUTABLE
Replace the first word of (unindented) test commands. This option replaces the first word of all test commands with something else,
which can be useful for testing alternate versions of a program. Commands which have been indented by one or more spaces will not
be affected by this option.
--debug
Show debug info, for troubleshooting
--debug-parse
Show test file parsing info and stop
--help-format
Display test format help
-?, --help
Display help message
-V, --version
Print version information
-- TFOPTIONS
Set extra test-framework options like -j/--threads, -t/--select-tests, -o/--timeout, --hide-successes. Use -- --help for a list.
Avoid spaces.
DEFINING TESTS
Test files, typically named tests/*.test, contain one or more tests consisting of:
o a one-line command
o optional standard input (<<<), standard output (>>>) and/or standard error output (>>>2) specifications
o an exit status (>>>=) specification
Test format:
# optional comment
the command to test
<<<
zero or more lines of standard input
>>>
zero or more lines of expected standard output
(or /REGEXP/ added to the previous line)
>>>2
zero or more lines of expected standard error output
(or /REGEXP/ added to the previous line)
>>>= EXITCODE (or /REGEXP/)
o A /REGEXP/ pattern may be used instead of explicit data. In this case a match anywhere in the output allows the test to pass. The regu-
lar expression syntax is regex-tdfa (http://hackage.haskell.org/package/regex-tdfa)'s.
o EXITCODE is a numeric exit status (http://en.wikipedia.org/wiki/Exit_status), eg 0 for a successful exit.
o You can put ! before a /REGEXP/ or EXITCODE to negate the match.
o Comment lines beginning with # may be used between tests.
EXAMPLES
Here's example.test, a file containing two simple tests:
# 1. let's test that echo runs. Numbering your tests can be helpful.
echo
>>>= 0
# 2. and now the cat command. On windows, this one should fail.
cat
<<<
foo
>>>
foo
>>>= 0
Run it with shelltest:
$ shelltest example.test
:t.test:1: [OK]
:t.test:2: [OK]
Test Cases Total
Passed 2 2
Failed 0 0
Total 2 2
AUTHORS
Simon Michael.
shelltestrunner March 18 2012 SHELLTEST(1)