Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Andrzejek on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Quick query 1

Status
Not open for further replies.

chris01010

Programmer
Jan 29, 2004
25
GB
Just a quick question.

What is the difference between executing a script command
using

./usr/local/blah/blah/blah.ksh

and

/usr/local/blah/blah/blah.ksh

Thanks

Chris
 
You have to understand the difference between relative and absolute pathnames.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Make sure you also know the difference between...

[tt] . /path/to/script.ksh[/tt]

...and...

[tt] /path/to/script.ksh[/tt]

The dot with a space after it means to run the commands in the script in THIS process. Otherwise it will create a separate subprocess to run the script in. Running it with the dot is called "sourcing" it.

The biggest difference is that if the script is going to be setting some environment variables that you want to be set when it's done, you have to source it to run it (that is, use the "dot space").

If you run the script without the dot, it will run the script, and possible set environment variables, but when the script ends, those variables are gone because they were only set for that process that was created to run the script.

Another thing is that when sourced, or run with a dot, the she-bang line (#!/bin/ksh) isn't used. It's just a comment. so you have to make sure you're running it in the correct shell.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top