error in script

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

error in script

Jon Miller-5
Trying to run a test to see if certain files exists in a certain location
using the following:
# Check files at location
LOCSAV="/usr/local/sop"
if [ -e $(ls -l $LOCSAV/*.ide) ]
it comes up with an error, can some lend a hand in fixing this?

Thanks

TEXT.htm (642 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: error in script

BTP-2
Check out

http://www.tldp.org/LDP/abs/html/

a bash scripting guide that should answer all your questions and show you plenty of examples.

You also might want to look up the "find" command in the man pages that might be better suited for your task.


On 1/25/06, Jon Miller <[hidden email]> wrote:
Trying to run a test to see if certain files exists in a certain location
using the following:
# Check files at location
LOCSAV="/usr/local/sop"
if [ -e $(ls -l $LOCSAV/*.ide) ]
it comes up with an error, can some lend a hand in fixing this?

Thanks



Reply | Threaded
Open this post in threaded view
|

Re: error in script

roach-6
In reply to this post by Jon Miller-5
On Wednesday 25 January 2006 20:10, Jon  Miller wrote:
<...>
> LOCSAV="/usr/local/sop"
> if [ -e $(ls -l $LOCSAV/*.ide) ]
> it comes up with an error, can some lend a hand in fixing this?

Why make it so complicated?
And what was, the exact, error message?
What shell are you using?

Try:

if [ -e $LOCSAV/*.ide ]

... it works here, with bash.

BTW, please set your list mail to text only. Your mailer's sending text, HTML
and an error message.

Thanks.
All the best.

--
Robert "roach" Spencer
Pietermaritzburg
South Africa


--
To UNSUBSCRIBE, email to [hidden email]
with a subject of "unsubscribe". Trouble? Contact [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: error in script

David Jardine
On Wed, Jan 25, 2006 at 11:48:47PM +0200, roach wrote:

> On Wednesday 25 January 2006 20:10, Jon  Miller wrote:
> <...>
> > LOCSAV="/usr/local/sop"
> > if [ -e $(ls -l $LOCSAV/*.ide) ]
> > it comes up with an error, can some lend a hand in fixing this?
>
> Why make it so complicated?
> And what was, the exact, error message?
> What shell are you using?
>
> Try:
>
> if [ -e $LOCSAV/*.ide ]
>
> ... it works here, with bash.

I don't think it will work if you have more than one such file.

if [ `ls $LOCSAV | grep '.ide$'` > 0 ]

might do the trick.

>
> BTW, please set your list mail to text only. Your mailer's sending text, HTML
> and an error message.
>
> Thanks.
> All the best.
>
> --
> Robert "roach" Spencer
> Pietermaritzburg
> South Africa
>
>
> --
> To UNSUBSCRIBE, email to [hidden email]
> with a subject of "unsubscribe". Trouble? Contact [hidden email]
>

--
David Jardine

"Running Debian GNU/Linux and
loving every minute of it."  -L. von Sacher-M.(1835-1895)


--
To UNSUBSCRIBE, email to [hidden email]
with a subject of "unsubscribe". Trouble? Contact [hidden email]