setting directory variable?

I have the following script and would like to know how to set the variable correctly.

FTP downloads the .rpm to the current directory, so the RPM command needs to know the directory it is in.

I could use ./test-application-1.0.i386.rpm to execute the command, but is there a way to set the variable, where CWD= current directory?

#!/bin/sh

CWD='???'

wget ftp://ftp:password@10.10.1.1://test-application-1.0.i386.rpm 

rpm -i /$CWD/test-application-1.0.i386.rpm

eof

I would think you could just:

rpm -i `pwd`/test-app-1.i386.rpm

or

CWD=`pwd`

Or just change CWD to PWD...

CWD='pwd'

I tried that, but it comes out as:

rpm -i /pwd/test-app-1/i386.rpm

it reads as text and not as a command

You used single quotes, not backticks. single quote: ' backtick: `. Very subtle but not the same!

In any case backticks are not POSIX standard. You should use $(pwd). I don't know why anyone uses backticks actually, they're a nightmare to see sometimes!

In any case on top of that, changing CWD to PWD is easier!

Thanks Peterro

Thanks Scottn - I didn't even know that key existed. That solved it for me.

That's cool :slight_smile: