The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > OS Specific Forums > AIX
Google UNIX.COM


AIX AIX is IBM's industry-leading UNIX operating system that meets the demands of applications that businesses rely upon in today's marketplace.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Calling expect scripts from other expect scripts seva Shell Programming and Scripting 0 04-03-2008 10:45 AM
FTP Scripts raghav1982 Shell Programming and Scripting 27 12-07-2007 03:38 AM
use of ssh in scripts esham Shell Programming and Scripting 7 11-16-2005 08:27 AM
Help with GDL to SQL scripts ch4r1e5 Shell Programming and Scripting 0 10-31-2005 02:51 PM
using su in scripts uchachra UNIX for Dummies Questions & Answers 3 03-11-2002 10:24 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 04-04-2008
Registered User
 

Join Date: Mar 2008
Posts: 26
To run scripts

How to run a script from any directory?

Should i include any environment or wat should i start with in writing a script ?
Reply With Quote
Forum Sponsor
  #2  
Old 04-04-2008
Bughunter Extraordinaire
 

Join Date: May 2005
Location: In the leftmost byte of /dev/kmem
Posts: 1,262
Without assuming completeness:

- make all the paths inside the script absolute. "/x/y/z" will always refer to the same place, "./a/b/c" will not

- set the environment explicitly. You might not need that for scripts run from the commandline, but once you put the script into cron the environment is different (in this case: non-existent). Scripts which "work" on the commandline but not from cron because of this make a good part of the problems in "Shell Programming and Scripting" forum.

If you want a truly encapsulated solution you can use an external shell function for the environment and put this function into a "library". Analogous to the "PATH" variable there is a "FPATH" variable which can be set to a list of directories. It tells the shell where to search for external functions.

- all the rules of software engineering apply. Just because it is a script language does not exempt you from the necessity to document, encapsulate, strucurize, .... your code. If you wouldn't do it in a high-level language you shouldn't do it in a script either.

I hope this helps.

bakunin
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 07:02 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0