After this function is called, userid is left as "user0". Although inside the while loop, if I print userid, it printd "user1" and "user2".
Note: MY_DIR/user_accounts is a text file with 2 lines:
node1 user1
node2 user2
If I comment out cat & read and instead manually assign line as "node1 user1", userid gets set to user1 correctly. What could be wrong here? Is it a variable scoping issue? I printed pid after each line, and it is the same pid. Also, this script runs fine in Solaris. It has issues only in Linux. Pl. help.
-Jasmeet
Last edited by Perderabo; 09-28-2005 at 04:16 PM..
Reason: Disable simlies and add code tags for readability
I hate to post something so n00bish, but I'm pretty n00bish when it comes to perl so here it goes:
$var=1;
while(1){
if ($var == 2){
last;
}
$var=2;
}
works the way I intend it to, breaking the infinite loop after the first time through, but: (2 Replies)
This may be a stupid question, but was wondering if it is possible to make a variable local to a particular script and invisible to an external script that may source the script where it is defined? Thanks as always (2 Replies)
Hi There,
I am writing a ksh script which assigns variable values from file "A" and passes that variables to file "B". While passing the parameters an additional "$" sign is being assigned to awk -v option.
Could any one help me with this please.
#!/bin/ksh
head -1... (3 Replies)
Hi,
Can any body please tell me what does -z do in ksh?
I need to understand what does below code do?
FILE_LIST is an array which store multiple number of files...
if } ]]; then
echo "EVDO file not found
fi
I hope I'm clear on my query (3 Replies)
Hello,
First post for Newbie as I am stumped. I need to get certain elements for a specific PID from the ps command. I am attempting to pass the value for the PID I want to retrieve the information for as a variable. When the following is run without using a variable, setting a specific PID,... (3 Replies)
Hi All,
I am using the below script which has awk command, but it is not returing the expected result. can some pls help me to correct the command.
The below script sample.ksh should give the result if the value of last 4 digits in the variable NM matches with the variable value DAT. The... (7 Replies)
Hello,
I have used a chunk of ksh script similar to this in many places without any issue:
while :
do
print;
read OPTION?"Enter a number (q to quit): "
expr ${OPTION} + 1 >/dev/null 2>&1
CHECKVAL=$?
if }" != ${OPTION} ]; then
... (2 Replies)
Greetings Experts,
I need to pass a parameter to ksh and the value is windows path eg: sh abc.txt C:\Users\chill3chee\Desktop
No matter I try with \ delimiter, still could not get this exact value assigned to the shell variable which was checked with echo. Tried with using... (2 Replies)
Hello,
I am trying to concatenate a string in a bash script like this:
runCmd="docker run -e \"IMAGE_NAME=$IMAGE_NAME\" "
env | grep "$ENV_SUFFIX" | while read line; do
envCmd="-e \"${line}\" "
runCmd=$runCmd$envCmd
echo $runCmd # here concatenation works fine
done
echo... (3 Replies)
Discussion started by: czabak
3 Replies
LEARN ABOUT SUSE
net::server::daemonize
Net::Server::Daemonize(3) User Contributed Perl Documentation Net::Server::Daemonize(3)NAME
Net::Server::Daemonize - Safe fork and daemonization utilities
SYNOPSIS
use Net::Server::Daemonize qw(daemonize);
daemonize(
'nobody', # User
'nobody', # Group
'/var/state/mydaemon.pid' # Path to PID file - optional
);
DESCRIPTION
This module is intended to let you simply and safely daemonize your server on systems supporting the POSIX module. This means that your
Perl script runs in the background, and it's process ID is stored in a file so you can easily stop it later.
EXPORTED FUNCTIONS
daemonize
Main routine. Arguments are user (or userid), group (or group id or space delimited list of groups), and pid_file (path to file).
This routine will check on the pid file, safely fork, create the pid file (storing the pid in the file), become another user and group,
close STDIN, STDOUT and STDERR, separate from the process group (become session leader), and install $SIG{INT} to remove the pid file.
In otherwords - daemonize. All errors result in a die. As of version 0.89 the pid_file is optional.
safe_fork
Block SIGINT during fork. No arguments. Returns pid of forked child. All errors result in a die.
set_user
Become another user and group. Arguments are user (or userid) and group (or group id or space delimited list of groups).
set_uid
Become another user. Argument is user (or userid). All errors die.
set_gid
Become another group. Arguments are groups (or group ids or space delimited list of groups or group ids). All errors die.
get_uid
Find the uid. Argument is user (userid returns userid). Returns userid. All errors die.
get_gid
Find the gids. Arguments are groups or space delimited list of groups. All errors die.
is_root_user
Determine if the process is running as root. Returns 1 or undef.
check_pid_file
Arguments are pid_file (full path to pid_file). Checks for existance of pid_file. If file exists, open it and determine if the
process that created it is still running. This is done first by checking for a /proc file system and second using a "ps" command (BSD
syntax). (If neither of these options exist it assumed that the process has ended) If the process is still running, it aborts.
Otherwise, returns true. All errors die.
create_pid_file.
Arguments are pid_file (full path to pid_file). Calls check_pid_file. If it is successful (no pid_file exists), creates a pid file
and stores $$ in the file.
unlink_pid_file
Does just that.
SEE ALSO
Net::Server. Net::Daemon, The Perl Cookbook Recipe 17.15.
AUTHORS
Jeremy Howard <j+daemonize@howard.fm>
Program flow, concepts and initial work.
Paul Seamons <paul@seamons.com>
Code rework and componentization. Ongoing maintainer.
LICENSE
This package may be distributed under the terms of either the
GNU General Public License
or the
Perl Artistic License
All rights reserved.
perl v5.12.1 2007-02-03 Net::Server::Daemonize(3)