• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2904
  • Last Modified:

Unix ls --- No such file or directory

I need to capture the condition when jversion returns No such file or directory... ..


jversion=`ls -1td /sbcimp/run/tp/sun/jre/*-64bit* | head -1 | cut -d'/' -f7 | sed 's/v//' | tr -s " " | sed 's/^[ ]//g'`
 
if [????] 
else
fi

Open in new window

0
tomerps
Asked:
tomerps
  • 3
  • 2
  • 2
1 Solution
 
ozoCommented:
is No such file or directory returned in $jversion? or is $jversion blank when ls -1td /sbcimp/run/tp/sun/jre/*-64bit*  prints No such file or directory on stderr?
0
 
tomerpsAuthor Commented:
Hi ozo, thanks for asking...it is done now. i captured the condition with followig code

if [ "$jversion"  = "No match" ] || [ "$jversion" = "0" ] || [ "$jversion" = "" ]
then
....


0
 
ozoCommented:
you can make the ls -1td /sbcimp/run/tp/sun/jre/*-64bit* send the No such file or directory error down the pipe to $jversion with ls -1td /sbcimp/run/tp/sun/jre/*-64bit* 2>&1

or you can test for $jversion being blank with
if [ ! $jversionjversion ] ; then
   echo No such file or directory
else
   echo $jversionjversion
fi
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
mikelfritzCommented:
I think ozo answered and should be rewarded to some degree.
0
 
mikelfritzCommented:
agreed
0
 
tomerpsAuthor Commented:
n/a
0
 
mikelfritzCommented:
Do as you like.  I was not involved until the end - on points and fairness only.  I think ozo's answer is perectly valid and shows how the pipes work; beyond that he/she deserves some credit.



0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now