Sponsored Content
Full Discussion: Shell script error
Top Forums Shell Programming and Scripting Shell script error Post 302943515 by Don Cragun on Saturday 9th of May 2015 07:34:05 AM
Old 05-09-2015
The PATH variable should NEVER be used to pass a pathname to a script nor be used within a script as a general variable holding a pathname.

The PATH variable has a very special meaning to any shell based on Bourne shell syntax (including all shells that conform to the IEEE and ISO POSIX standards and The Open Group's Single UNIX Specifications); it is a colon separated list of directories containing the utilities to be executed by that shell that are invoked with no slash characters in their pathname.

If you are saying that you want the normal setting of $PATH to find grep, ps, and mailx and need to add /usr/local/bin to find sudo;
either:
  • set PATH using PATH="/usr/local/bin:$PATH", or
  • leave PATH alone and change the invocation of sudo to /usr/local/bin/sudo /oes/oracle stop.
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

error in shell script

Hi, I have written a small shell script which logs into each oracle database on the server and displays whether it is in archivelog mode or not.. The script is as under: #!/bin/bash dblist=`ps -ef | grep smon | grep -v grep |cut -d'_' -f3` for ohome in $dblist; do sqlplus -s /nolog <<... (2 Replies)
Discussion started by: jalpan.pota
2 Replies

2. UNIX for Dummies Questions & Answers

awk Shell Script error : "Syntax Error : `Split' unexpected

hi there i write one awk script file in shell programing the code is related to dd/mm/yy to month, day year format but i get an error please can anybody help me out in this problem ?????? i give my code here including error awk ` # date-month -- convert mm/dd/yy to month day,... (2 Replies)
Discussion started by: Herry
2 Replies

3. Shell Programming and Scripting

Shell script error

Hi, I have the following table in MYSQL: (the structure looks broken in this forum but if you copy/paste it into notepad, it'll look right): +----------------------------+-----------------------+------+-----+---------+----------------+ | Field | Type |... (0 Replies)
Discussion started by: tezarin
0 Replies

4. Shell Programming and Scripting

How to grep sql error in shell script and exit the script?

I need help in the following script. I want to grep the sql errors insert into the error table and exit the shell script if there is any error, otherwise keep running the scripts. Here is my script #!/bin/csh -f source .orapass set user = $USER set pass = $PASS cd /opt/data/scripts echo... (2 Replies)
Discussion started by: allinshell99
2 Replies

5. Shell Programming and Scripting

Error in Shell script

Hello All, I am newbe to scripting and have just taken over following script from previous developer. I am getting following error when running the script. line 70: syntax error near unexpected token `do Could some help me to rectify the error please. Thanks in advance for your... (9 Replies)
Discussion started by: Pahadia
9 Replies

6. Shell Programming and Scripting

Syntax error calling TCL script from shell script

hello everyone i am beginner on shell scripting .and i am working on my project work on ad hoc network i wrote a batch (.sh) to do a looping and execute a tcl script i wrote before in each iteration ..but i got this problem " syntax error near unexpected token `('... (1 Reply)
Discussion started by: marcoss90
1 Replies

7. Shell Programming and Scripting

Error in calling a shell script from another script

HI, We are using two shell scripts, script.sh,env.sh, where env.sh will be called inside script.sh. The variable inside env.sh is used as $var in script.sh.But while running the script its not identifying that variable. Is there any permission needed to call a script inside another script. ... (3 Replies)
Discussion started by: banupriyat
3 Replies

8. Shell Programming and Scripting

Calling shell script within awk script throws error

I am getting the following error while passing parameter to a shell script called within awk script. Any idea what's causing this issue and how to ix it ? Thanks sh: -c: line 0: syntax error near unexpected token `newline' sh: -c: line 0: `./billdatecalc.sh ... (10 Replies)
Discussion started by: Sudhakar333
10 Replies

9. Shell Programming and Scripting

Shell script with sql script error

Hi All when I execute from psql prompt, I get the result, when I try to automate using a shell script, the query is not working # `/usr/bin/psql -U postgres -d coba1 -c "select name from users where "Date" > current_date - 30;"` ERROR: column "Date" does not exist LINE 1: select... (2 Replies)
Discussion started by: srilinux09
2 Replies
command(1)							   User Commands							command(1)

NAME
command - execute a simple command SYNOPSIS
/usr/bin/command command [-p] command_name [argument]... command [-v | -V] command_name ksh93 command [-pvxV] [command_name [argument...]] DESCRIPTION
The command utility causes the shell to treat the arguments as a simple command, suppressing the shell function lookup. If the command_name is the same as the name of one of the special built-in utilities, the special properties do not occur. In every other respect, if command_name is not the name of a function, the effect of command (with no options) are the same as omitting command. The command utility also provides information concerning how a command name is interpreted by the shell. See -v and -V. ksh93 Without the -v or -V option, command executes command_name with arguments specified by argument, suppressing the shell function lookup that normally occurs. In addition, if command is a special built-in command, the special properties are removed so that failures do not cause the script that executes it to terminate. If the -v or -V options are specified, command is equivalent to whence(1). OPTIONS
The following options are supported by /usr/bin/command: -p Performs the command search using a default value for PATH that is guaranteed to find all of the standard utilities. -v Writes a string to standard output that indicates the path or command that is be used by the shell, in the current shell execution environment to invoke command_name, but does not invoke command_name. o Utilities, regular built-in utilities, command_names including a slash character, and any implementation-provided func- tions that are found using the PATH variable is written as absolute path names. o Shell functions, special built-in utilities, regular built-in utilities not associated with a PATH search, and shell reserved words are written as just their names. o An alias is written as a command line that represents its alias definition. o Otherwise, no output is written and the exit status reflects that the name was not found. -V Writes a string to standard output that indicates how the name specified in the command_name operand is interpreted by the shell, in the current shell execution environment, but does not invoke command_name. Although the format of this string is unspecified, it indicates in which of the following categories command_name falls and include the information stated: o Utilities, regular built-in utilities, and any implementation-provided functions that are found using the PATH variable is identified as such and include the absolute path name in the string. o Other shell functions is identified as functions. o Aliases are identified as aliases and their definitions are included in the string. o Special built-in utilities are identified as special built-in utilities. o Regular built-in utilities not associated with a PATH search is identified as regular built-in utilities. o Shell reserved words are identified as reserved words. ksh93 The following options are supported by ksh93 command: -p Causes a default path to be searched rather than the one defined by the value of PATH. -v Equivalent to: whence command [argument ...] -V Equivalent to: whence -v command [argument ...] -x If command fails because there are too many arguments, it is invoked multiple times with a subset of the arguments on each invoca- tion. Arguments that occur prior to the first word that expand to multiple arguments and arguments that occur after the last word that expands to multiple arguments are passed on each invocation. The exit status is the maximum invocation exit status. OPERANDS
The following operands are supported: argument One of the strings treated as an argument to command_name. command_name The name of a utility or a special built-in utility. EXAMPLES
Example 1 Making a Version of cd That Always Prints Out the New Working Directory The following example takes a version of cd that always prints out the new working directory exactly once: cd() { command cd "$@" >/dev/null pwd } Example 2 Starting Off a secure shell script in Which the Script Avoids Being Spoofed by Its Parent The following example starts off a secure shell script in which the script avoids being spoofed by its parent: IFS=' ' # The preceding value should be <space><tab><newline>. # Set IFS to its default value. unalias -a # Unset all possible aliases. # Note that unalias is escaped to prevent an alias # being used for unalias. unset -f command # Ensure command is not a user function. PATH="$(command -p getconf _CS_PATH):$PATH" # Put on a reliable PATH prefix. # ... At this point, given correct permissions on the directories called by PATH, the script has the ability to ensure that any utility it calls is the intended one. It is being very cautious because it assumes that implementation extensions can be present that would allow user func- tions to exist when it is invoked. This capability is not specified by this document, but it is not prohibited as an extension. For exam- ple, the ENV variable precedes the invocation of the script with a user startup script. Such a script could define functions to spoof the application. ENVIRONMENT VARIABLES
See environ(5) for descriptions of the following environment variables that affect the execution of command: LANG, LC_ALL, LC_CTYPE, LC_MESSAGES, and NLSPATH. PATH Determine the search path used during the command search, except as described under the -p option. EXIT STATUS
/usr/bin/command When the -v or -V options are specified, the following exit values are returned: 0 Successful completion. >0 The command_name could not be found or an error occurred. Otherwise, the following exit values are returned: 126 The utility specified by command_name was found but could not be invoked. 127 An error occurred in the command utility or the utility specified by command_name could not be found. Otherwise, the exit status of command is that of the simple command specified by the arguments to command. ksh93 If command is invoked, the exit status of command is that of command. Otherwise, it is one of the following: 0 command_name completed successfully. >0 -v or -V has been specified and an error occurred. 126 command_name was found but could not be invoked. 127 command_name could not be found. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: /usr/bin/command +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ |Interface Stability |Committed | +-----------------------------+-----------------------------+ |Standard |See standards(5). | +-----------------------------+-----------------------------+ ksh93 +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ |Interface Stability |Uncommitted | +-----------------------------+-----------------------------+ SEE ALSO
ksh93(1), sh(1), type(1), whence(1), attributes(5), environ(5), standards(5) SunOS 5.11 8 Apr 2008 command(1)
All times are GMT -4. The time now is 08:33 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy