Sponsored Content
Operating Systems Linux UNIX Utility Development Conventions? Post 303040873 by vbe on Friday 8th of November 2019 05:18:38 AM
Old 11-08-2019
Greetings, and welcome!

This is not a forum for Hackers so if that is your purpose, it is pointless to post here, you will be banned very shortly...

You mention you are in the process of developing a utility, fine only we cant help you not knowing what is its purpose, from what I understand its a shell script, as such there are no true standards, as you are free to implement whatever the way you want, it gets more tricky if the idea is that it should have a natural UNIX feeling, in such case look how the different vendors implement their stuff and find a suitable compromise, knowing there are rules on man pages ( 1: users, 1M: system administration etc...)

For the rest, up to you but the main point is more you make things complex more you suffer to maintain and update, using ordinary good coding practice and keeping up the documentation in the script is essential, 4-5 undocumented modifications, and suddenly you fall on a side effect bug, you will spend quite some time to figure out what is going on...

We are always ready and interested to see what people are capable to achieve in shell scripts only the rules here are :
  1. - You explain your goals
  2. - You show ( code) what you have done so far, if with issues then with error output
  3. - When someone corrects or give you some code, you test it and give us some feedback
  4. - You accept to be open-minded as, see first rules, depending of your level of understanding and knowledge, you may see some here have quite some imagination.. and you will have many different solutions to your aims, and the best way to learn is to test them all and ask for what you don't understand in the code, or procedure, as we all have different background our ways of resolving depends of our experience...

So the is not much more to say until we know a bit more about your project...
These 2 Users Gave Thanks to vbe For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Problem with tip utility in unix

Hi , I have wrote a telnet clinet application to interact with remote system . This program takes the screen shots for every interaction and send back to us. After connecting to remote machine , i want to call tip utility to interact with a device which is connected to one remote system. Now my... (0 Replies)
Discussion started by: prasadvsda
0 Replies

2. SCO

Zip utility in sco unix

how can zip a directory in sco unix and transfer it to any other system using ftp. and finally how can i unzip it regards, ajay (1 Reply)
Discussion started by: ajay234
1 Replies

3. Shell Programming and Scripting

VLOOKUP utility in UNIX

Kindly help me to build the script similar to VLOOKUP function of MS Excell. (5 Replies)
Discussion started by: hjoshi
5 Replies

4. UNIX for Dummies Questions & Answers

age utility in unix

Hi, Can anyone explain me the use of age utility and how it works? Looking forward reply... Thanks, Venkatesh. (1 Reply)
Discussion started by: venkatesht
1 Replies

5. UNIX for Dummies Questions & Answers

Best unix incremental backup utility?

Hello everyone. Could you please advise of what would be the best Unix (Debian 4) program for regular (daily or weekly) incremental backups? I'm not sure whether the backups will be stored on a "backup" drive on the same system or on an external "backup" system, but we would like to have a... (2 Replies)
Discussion started by: nottrobin
2 Replies

6. Programming

c calling conventions

C calling convention we all know defines a way how the parameters are pushed onto the stack. My question is when and how does this C calling conventions matters to a user? When the user will have to bother about the calling conventions in his project? (5 Replies)
Discussion started by: rupeshkp728
5 Replies

7. UNIX for Dummies Questions & Answers

file hashing utility in unix

I am looking for a utility that does file hashing in unix. ...Please let me know of any good easy to use utility (3 Replies)
Discussion started by: jbjoat
3 Replies

8. UNIX for Dummies Questions & Answers

Typographic conventions in bash 4.2

is there a typographic convention that is followed in the man pages. where could a description be found. at this time i am in man stty and the author uses upper case in some places. and my brain is just burning to a fizzle while studying a book on bash and trying to stay in scope of the... (1 Reply)
Discussion started by: cowLips
1 Replies

9. UNIX for Beginners Questions & Answers

UNIX mail utility

Hi, I work on a Middleware application which is installed on Windows, but its file System is on HP UNIX. I am supposed to change the SMTP host address for my application. But I am not able to find the file where the old SMTP host would have been configured/hardcoded. Can anyone assist me on this... (2 Replies)
Discussion started by: jhilmil
2 Replies

10. Cybersecurity

Proper naming conventions

Hey guys, not sure should I post it here or in 'What is on Your Mind?' I'm discussing usage of DSL (domain specific language) in security tools with my colleagues. We haven't been able to reach an agreement over naming conventions. There are many tools using DSL: splunk, sumologic,... (2 Replies)
Discussion started by: Tobby P
2 Replies
pkg_mkIndex(n)						       Tcl Built-In Commands						    pkg_mkIndex(n)

__________________________________________________________________________________________________________________________________________________

NAME
pkg_mkIndex - Build an index for automatic loading of packages SYNOPSIS
pkg_mkIndex ?-direct? ?-lazy? ?-load pkgPat? ?-verbose? dir ?pattern pattern ...? _________________________________________________________________ DESCRIPTION
Pkg_mkIndex is a utility procedure that is part of the standard Tcl library. It is used to create index files that allow packages to be loaded automatically when package require commands are executed. To use pkg_mkIndex, follow these steps: [1] Create the package(s). Each package may consist of one or more Tcl script files or binary files. Binary files must be suitable for loading with the load command with a single argument; for example, if the file is test.so it must be possible to load this file with the command load test.so. Each script file must contain a package provide command to declare the package and version number, and each binary file must contain a call to Tcl_PkgProvide. [2] Create the index by invoking pkg_mkIndex. The dir argument gives the name of a directory and each pattern argument is a glob-style pattern that selects script or binary files in dir. The default pattern is *.tcl and *.[info sharedlibextension]. Pkg_mkIndex will create a file pkgIndex.tcl in dir with package information about all the files given by the pattern arguments. It does this by loading each file into a slave interpreter and seeing what packages and new commands appear (this is why it is essen- tial to have package provide commands or Tcl_PkgProvide calls in the files, as described above). If you have a package split among scripts and binary files, or if you have dependencies among files, you may have to use the -load option or adjust the order in which pkg_mkIndex processes the files. See COMPLEX CASES below. [3] Install the package as a subdirectory of one of the directories given by the tcl_pkgPath variable. If $tcl_pkgPath contains more than one directory, machine-dependent packages (e.g., those that contain binary shared libraries) should normally be installed under the first directory and machine-independent packages (e.g., those that contain only Tcl scripts) should be installed under the sec- ond directory. The subdirectory should include the package's script and/or binary files as well as the pkgIndex.tcl file. As long as the package is installed as a subdirectory of a directory in $tcl_pkgPath it will automatically be found during package require commands. If you install the package anywhere else, then you must ensure that the directory containing the package is in the auto_path global variable or an immediate subdirectory of one of the directories in auto_path. Auto_path contains a list of directories that are searched by both the auto-loader and the package loader; by default it includes $tcl_pkgPath. The package loader also checks all of the subdirectories of the directories in auto_path. You can add a directory to auto_path explicitly in your application, or you can add the directory to your TCLLIBPATH environment variable: if this environment variable is present, Tcl initializes auto_path from it during application startup. [4] Once the above steps have been taken, all you need to do to use a package is to invoke package require. For example, if versions 2.1, 2.3, and 3.1 of package Test have been indexed by pkg_mkIndex, the command package require Test will make version 3.1 available and the command package require -exact Test 2.1 will make version 2.1 available. There may be many versions of a package in the various index files in auto_path, but only one will actually be loaded in a given interpreter, based on the first call to package require. Different versions of a package may be loaded in different interpreters. OPTIONS
The optional switches are: -direct The generated index will implement direct loading of the package upon package require. This is the default. -lazy The generated index will manage to delay loading the package until the use of one of the commands provided by the package, instead of loading it immediately upon package require. This is not compatible with the use of auto_reset, and therefore its use is discouraged. -load pkgPat The index process will pre-load any packages that exist in the current interpreter and match pkgPat into the slave inter- preter used to generate the index. The pattern match uses string match rules, but without making case distinctions. See COMPLEX CASES below. -verbose Generate output during the indexing process. Output is via the tclLog procedure, which by default prints to stderr. -- End of the flags, in case dir begins with a dash. PACKAGES AND THE AUTO-LOADER The package management facilities overlap somewhat with the auto-loader, in that both arrange for files to be loaded on-demand. However, package management is a higher-level mechanism that uses the auto-loader for the last step in the loading process. It is generally better to index a package with pkg_mkIndex rather than auto_mkindex because the package mechanism provides version control: several versions of a package can be made available in the index files, with different applications using different versions based on package require commands. In contrast, auto_mkindex does not understand versions so it can only handle a single version of each package. It is probably not a good idea to index a given package with both pkg_mkIndex and auto_mkindex. If you use pkg_mkIndex to index a package, its commands cannot be invoked until package require has been used to select a version; in contrast, packages indexed with auto_mkindex can be used immediately since there is no version control. HOW IT WORKS
Pkg_mkIndex depends on the package unknown command, the package ifneeded command, and the auto-loader. The first time a package require command is invoked, the package unknown script is invoked. This is set by Tcl initialization to a script that evaluates all of the pkgIn- dex.tcl files in the auto_path. The pkgIndex.tcl files contain package ifneeded commands for each version of each available package; these commands invoke package provide commands to announce the availability of the package, and they setup auto-loader information to load the files of the package. If the -lazy flag was provided when the pkgIndex.tcl was generated, a given file of a given version of a given package is not actually loaded until the first time one of its commands is invoked. Thus, after invoking package require you may not see the package's commands in the interpreter, but you will be able to invoke the commands and they will be auto-loaded. DIRECT LOADING
Some packages, for instance packages which use namespaces and export commands or those which require special initialization, might select that their package files be loaded immediately upon package require instead of delaying the actual loading to the first use of one of the package's command. This is the default mode when generating the package index. It can be overridden by specifying the -lazy argument. COMPLEX CASES
Most complex cases of dependencies among scripts and binary files, and packages being split among scripts and binary files are handled OK. However, you may have to adjust the order in which files are processed by pkg_mkIndex. These issues are described in detail below. If each script or file contains one package, and packages are only contained in one file, then things are easy. You simply specify all files to be indexed in any order with some glob patterns. In general, it is OK for scripts to have dependencies on other packages. If scripts contain package require commands, these are stubbed out in the interpreter used to process the scripts, so these do not cause problems. If scripts call into other packages in global code, these calls are handled by a stub unknown command. However, if scripts make variable references to other package's variables in global code, these will cause errors. That is also bad coding style. If binary files have dependencies on other packages, things can become tricky because it is not possible to stub out C-level APIs such as Tcl_PkgRequire API when loading a binary file. For example, suppose the BLT package requires Tk, and expresses this with a call to Tcl_PkgRequire in its Blt_Init routine. To support this, you must run pkg_mkIndex in an interpreter that has Tk loaded. You can achieve this with the -load pkgPat option. If you specify this option, pkg_mkIndex will load any packages listed by info loaded and that match pkgPat into the interpreter used to process files. In most cases this will satisfy the Tcl_PkgRequire calls made by binary files. If you are indexing two binary files and one depends on the other, you should specify the one that has dependencies last. This way the one without dependencies will get loaded and indexed, and then the package it provides will be available when the second file is processed. You may also need to load the first package into the temporary interpreter used to create the index by using the -load flag; it will not hurt to specify package patterns that are not yet loaded. If you have a package that is split across scripts and a binary file, then you should avoid the -load flag. The problem is that if you load a package before computing the index it masks any other files that provide part of the same package. If you must use -load, then you must specify the scripts first; otherwise the package loaded from the binary file may mask the package defined by the scripts. SEE ALSO
package(n) KEYWORDS
auto-load, index, package, version Tcl 8.3 pkg_mkIndex(n)
All times are GMT -4. The time now is 09:50 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy