Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Find the user executing a script Post 302076625 by sssow on Wednesday 14th of June 2006 03:39:20 PM
Old 06-14-2006
from within the script?
whoami shoud give the username

try echo $(whoami)
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Executing Script of a different user on Same Machine

Hi, I want to execute a script - of different user from my script. I have tried the su command su - username -c "scriptname" it works but asked for password. Is there any way for supplying the password to it thru script, not interactively. Or is there any other way to achieve the... (5 Replies)
Discussion started by: yeheyaansari
5 Replies

2. Shell Programming and Scripting

Shell script to find when user su'ed to root

Does anybody know how to make a shell script that finds all the times that any user su'ed to root and create a cron job sends that file output via e-mail to one user? Thanks!:confused: (1 Reply)
Discussion started by: jrvilino
1 Replies

3. SCO

Executing script with root privilages from a user login

I need to regular users to be able to launch a script which does something requiring root privilages. I've tried using chmod 4755 which gives it -rwsr-xr-x permissions but it still can not be run as the regular user. (1 Reply)
Discussion started by: checkpro
1 Replies

4. Shell Programming and Scripting

Find username of user running the script

Hello All, If I have a simple cgi script and want to find the name of the person accessing the page, is it possible? How do I get the name of this user? Please help. I was trying a vague method but it doesn't seem to work with all browsers and versions ... $val=$ENV{'HTTP_COOKIE'}; $name... (1 Reply)
Discussion started by: garric
1 Replies

5. Shell Programming and Scripting

Executing program with Perl script but needs user input

Hello, I'm running a perl script to execute a program through my Unix command line. The program requires a user input but I want to automatically have perl input the string. Is there a way to do this? Thanks (1 Reply)
Discussion started by: leonard2352
1 Replies

6. Shell Programming and Scripting

Script to find the user of a file and permissions

I have a list of files in a.txt file. For each of the files listed in that file, I would like to obtain the owner of the file and also, the permissions associated with that file. If possible, the group the owner belongs to as well. Can someone help me with a script to find that out. (1 Reply)
Discussion started by: ggayathri
1 Replies

7. Shell Programming and Scripting

getting a string from user while executing a tcl script

Hi All, I am executing a Tcl script and i am trying to get the user input while they execute the script at start itself like >>filename.tcl USERINPUT and then i will take this userinput inside the the tcl assign it to some variable for further manipulation/processing ...... can anyone pls... (1 Reply)
Discussion started by: sukrish
1 Replies

8. Shell Programming and Scripting

Knowing the user who is executing my script

Hi, is there any way? I thot of id but it doesnt work quite well :wall: (2 Replies)
Discussion started by: lamachejo
2 Replies

9. UNIX for Dummies Questions & Answers

How to switch the user before executing a shell script from web page??

hi, i want to execute a shell script as a different user. the flow is like this. there is a html web page from which i have to call a shell script. web server is apache. to call the shell script from html page, a perl script is required. so the html page calls the perl script and the perl... (2 Replies)
Discussion started by: Little
2 Replies

10. Solaris

How to find IP of user machine executing a particular UNIX command?

Hello, Our applications are deployed in SunOS 5.10 servers. All the team members use a same username/pwd to login to the box. Very often we face issue were we could see that weblogic server instance are KILLED and we are not able to trace who executed kill command. All team members use PUTTY to... (2 Replies)
Discussion started by: santtarius
2 Replies
COM_ERR(3)						   BSD Library Functions Manual 						COM_ERR(3)

NAME
com_err, com_err_va, error_message, error_table_name, init_error_table, set_com_err_hook, reset_com_err_hook, add_to_error_table, initialize_error_table_r free_error_table, com_right -- common error display library LIBRARY
Common Error Library (libcom_err, -lcom_err) SYNOPSIS
#include <stdio.h> #include <stdarg.h> #include <krb5/com_err.h> #include "XXX_err.h" typedef void (*errf)(const char *, long, const char *, ...); void com_err(const char *whoami, long code, const char *format, ...); void com_err_va(const char *whoami, long code, const char *format, ...); const char * error_message(long code); const char * error_table_name(int num); int init_error_table(const char **msgs, long base, int count); errf set_com_err_hook(errf func); errf reset_com_err_hook(); void add_to_error_table(struct et_list *new_table); void initialize_error_table_r(struct et_list **et_list, const char **msgs, int base, long count); void free_error_table(struct et_list *); const char * com_right(struct et_list *list, long, code"); DESCRIPTION
The com_err library provides a common error-reporting mechanism for defining and accessing error codes and descriptions for application soft- ware packages. Error descriptions are defined in a table and error codes are used to index the table. The error table, the descriptions and the error codes are generated using compile_et(1). The error table is registered with the com_err library by calling its initialisation function defined in its header file. The initialisation function is generally defined as initialize_<name>_error_table(), where name is the name of the error table. If a thread-safe version of the library is needed initialize_<name>_error_table_r() that internally calls initialize_error_table_r() instead be used. Any variable which is to contain an error code should be declared <name>_error_number where name is the name of the error table. FUNCTIONS
The following functions are available to the application developer: com_err(whoami, code, format, ...) Displays an error message on standard error composed of the whoami string, which should specify the program name, followed by an error message generated from code, and a string produced using the printf(3) format string and any following arguments. If format is NULL, the formatted message will not be printed. The argument format may not be omitted. com_err_va(whoami, code, format, va_list args) This routine provides an interface, equivalent to com_err(), which may be used by higher-level variadic functions (functions which accept variable numbers of arguments). error_message(code) Returns the character string error message associate with code. If code is associated with an unknown error table, or if code is associated with a known error table but is not in the table, a string of the form `Unknown code XXXX NN' is returned, where XXXX is the error table name produced by reversing the compaction performed on the error table number implied by that error code, and NN is the offset from that base value. Although this routine is available for use when needed, its use should be left to circumstances which render com_err() unusable. com_right() returns the error string just like com_err but in a thread-safe way. error_table_name(num) Convert a machine-independent error table number num into an error table name. init_error_table(msgs, base, count) Initialise the internal error table with the array of character string error messages in msgs of length count. The error codes are assigned incrementally from base. This function is useful for using the error-reporting mechanism with custom error tables that have not been generated with compile_et(1). Although this routine is available for use when needed, its use should be restricted. initialize_error_table_r() initialize the et_list in the same way as init_error_table(), but in a thread-safe way. set_com_err_hook(func) Provides a hook into the com_err library to allow the routine func to be dynamically substituted for com_err(). After set_com_err_hook() has been called, calls to com_err() will turn into calls to the new hook routine. This function is intended to be used in daemons to use a routine which calls syslog(3), or in a window system application to pop up a dialogue box. reset_com_err_hook() Turns off the hook set in set_com_err_hook(). add_to_error_table(new_table) Add the error table, its messages strings and error codes in new_table to the internal error table. EXAMPLES
The following is an example using the table defined in compile_et(1): #include <stdio.h> #include <stdarg.h> #include <syslog.h> #include "test_err.h" void hook(const char *whoami, long code, const char *format, va_list args) { char buffer[BUFSIZ]; static int initialized = 0; if (!initialized) { openlog(whoami, LOG_NOWAIT, LOG_DAEMON); initialized = 1; } vsprintf(buffer, format, args); syslog(LOG_ERR, "%s %s", error_message(code), buffer); } int main(int argc, char *argv[]) { char *whoami = argv[0]; initialize_test_error_table(); com_err(whoami, TEST_INVAL, "before hook"); set_com_err_hook(hook); com_err(whoami, TEST_IO, "after hook"); return (0); } SEE ALSO
compile_et(1) BSD
July 7, 2005 BSD
All times are GMT -4. The time now is 05:25 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy