Because $0 inside a function is not the same as outside the function. Outside it is the name of the script, as you noticed and inside the function it is the function's positional parameters.
Besides that I can't see where you call this function at all so you might want to write something like:
Script 1.ksh
=========
/home/adw/a.ksh << **
a
b
Script 1.ksh is working fine even without ending "**"
Script 2.ksh
=========
if then
/home/adw/a.ksh << **
a
b
fi
But the script 2.ksh is giving error "syntax error : `<<' unmatched".
Is it bcoz of fi. (1 Reply)
hi,
I have this script which gives me the result...
#! /usr/bin/sh
set -x
cd /home/managar
a=1
while true
do
if
then
echo " File log.txt exists in this directory "
exit 0
fi
echo " File has not arrived yes..."
sleep 3
let a=a+1
if
then (1 Reply)
Hi,
I have a script in which an entry like this .....
FILENAME_B="PIC_${DATE}0732*.JPG"
The script connects to an ATM and pull a pic file from it.The format for the file is like PIC_2008061400000001.JPG in the ATM.
Means 1st 8 digit is the date(YYYYMMDD) field
2nd 8 digit means hrs... (2 Replies)
Hi All,
i have an small issue...
echo " "
eval x=$@
export x=`echo $x`
echo $x
ssh user@ipadrss; cd /mbbv/home/;
cd /mbbv/home/orange/orange/
echo pwd
bash samplescript.sh $x
above is my script which will triger from server A and will connect to server B for some... (2 Replies)
Hi all
Here I came accross a situation which i am unable to reason out...
snippet 1
psg ServTest | grep -v "grep" | grep -v "vi" | awk '{
pgm_name=$8
cmd_name="ServTest"
gsub(/]*/,"",pgm_name)
if(pgm_name==cmd_name) { print "ServTest Present =" cmd_name}
}'... (10 Replies)
Hi all,
I need some help in my script...
I need to login into multiple servers from one Unix box and need to login as a superuser account and then I need to perform some actions on the server. For this, i'll use for loop to provide the server names to the script, but for every login as a... (8 Replies)
Hi,
I am new to shell scripting and my below script is not giving result for 2 or more arguments. Can anyone help pls.
#!/bin/sh
sname=$(basename $(readlink -nf $0))
echo "This is $sname, running at $(date)"
echo "It is running on $(hostname)"
echo "Script being run by"
echo " User... (3 Replies)
Hi,
I am a newbie to scripting. I want to know something..Is there any way that I can do this?
Here is the thing.. there are so many printer queues in which i need to change a certain option.. am using the hppi utility and i need to modify the printer configuration individually going to each... (3 Replies)
Hi
Below is snippet from script which is not giving the o/p.script name is alarm.sh
#!/bin/sh
out=`awk '(NR>1) {print $9;exit}' alarm`
echo $a
however when i simply run the above command i an getting the o/p
$ out=`awk '(NR>1) {print $9;exit}' alarm`
$ echo $a
6... (2 Replies)
#!/bin/sh
#!/bin/prel
#set -x
while getopts ":n:t:" opt; do
case "$opt" in
n)
host=$OPTARG
;;
t)
targ=$OPTARG
;;
*)
break
;;
esac
done
if ping -c 2 $host >/dev/null 2>&1
then
echo Host... (17 Replies)
Discussion started by: Vishal_dba
17 Replies
LEARN ABOUT PHP
register_shutdown_function
REGISTER_SHUTDOWN_FUNCTION(3) 1 REGISTER_SHUTDOWN_FUNCTION(3)register_shutdown_function - Register a function for execution on shutdownSYNOPSIS
void register_shutdown_function (callable $callback, [mixed $parameter], [mixed $...])
DESCRIPTION
Registers a $callback to be executed after script execution finishes or exit(3) is called.
Multiple calls to register_shutdown_function(3) can be made, and each will be called in the same order as they were registered. If you
call exit(3) within one registered shutdown function, processing will stop completely and no other registered shutdown functions will be
called.
PARAMETERS
o $callback
- The shutdown callback to register. The shutdown callbacks are executed as the part of the request, so it's possible to send
output from them and access output buffers.
o $parameter
- It is possible to pass parameters to the shutdown function by passing additional parameters.
o $...
-
RETURN VALUES
No value is returned.
ERRORS /EXCEPTIONS
If the passed callback is not callable a E_WARNING level error will be generated.
EXAMPLES
Example #1
register_shutdown_function(3) example
<?php
function shutdown()
{
// This is our shutdown function, in
// here we can do any last operations
// before the script is complete.
echo 'Script executed with success', PHP_EOL;
}
register_shutdown_function('shutdown');
?>
NOTES
Note
Working directory of the script can change inside the shutdown function under some web servers, e.g. Apache.
Note
Shutdown functions will not be executed if the process is killed with a SIGTERM or SIGKILL signal. While you cannot intercept a
SIGKILL, you can use pcntl_signal(3) to install a handler for a SIGTERM which uses exit(3) to end cleanly.
SEE ALSO
auto_append_file, exit(3), The section on connection handling.
PHP Documentation Group REGISTER_SHUTDOWN_FUNCTION(3)