Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Why does "ps -[u|U] username" not list processes when username is numeric? Post 303039928 by Corona688 on Thursday 17th of October 2019 04:25:32 PM
Old 10-17-2019
What's your operating system? That's important for how ps behaves.

It can't match ID and name on numbers because that's ambiguous. There could be several "correct" entries, which isn't supposed to be possible.

If you're assigning these numbers arbitrarily, I'd suggest getting them from UNIX instead of giving them to UNIX.

If you have to deal with this as is, you may need to look up the UIDs in situ.
Code:
UID=$(awk -F: '$1 == NAME { print $3 ; exit }' NAME="12345" /etc/passwd)


Last edited by Corona688; 10-17-2019 at 05:34 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

check input = "empty" and "numeric"

Hi how to check input is "empty" and "numeric" in ksh? e.g: ./myscript.ksh k output show: invalid number input ./myscript.ksh output show: no input ./myscript.ksh 10 output show: input is numeric (6 Replies)
Discussion started by: geoffry
6 Replies

2. UNIX for Dummies Questions & Answers

Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`"

Hi Friends, Can any of you explain me about the below line of code? mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'` Im not able to understand, what exactly it is doing :confused: Any help would be useful for me. Lokesha (4 Replies)
Discussion started by: Lokesha
4 Replies

3. Solaris

Using all numeric for username

Hello, We have a Solaris 9 machine and recently our client want to create username based on staff numbers (all numeric). Is there any limitation in Solaris regarding creating username with numeric values (eg: 13598029)? Thanks & Regards Aryawarman Mahzar (5 Replies)
Discussion started by: aryamahzar
5 Replies

4. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

5. Shell Programming and Scripting

Read from "list1" and list matches in "list2"

I want to print any matching IP addresse in List1 with List 2; List 1 List of IP addresses; 161.85.58.210 250.57.15.129 217.23.162.249 74.76.129.101 30.221.177.237 3.147.200.59 170.58.142.64 127.65.109.33 150.167.242.146 223.3.20.186 25.181.180.99 2.55.199.32 (3 Replies)
Discussion started by: lewk
3 Replies

6. Shell Programming and Scripting

Passing username and password to a script running inside "expect" script

Hi I'm trying to run a script " abc.sh" which triggers "use.sh" . abc.sh is nothing but a "expect" script which provides username and password automatically to the use.sh script. Please find below the scripts: #abc.sh #!/usr/bin/expect -f exec /root/use.sh expect "*name*" send... (1 Reply)
Discussion started by: baddykam
1 Replies

7. SuSE

SUSE "passwd username" ask for password 4 times

Below is the error I'm getting. # passwd username Changing password for username. New Password: Reenter New Password: Password changed. New UNIX password: Retype new UNIX password: Password has been already used. Choose another. passwd: Authentication token manipulation error# cat... (0 Replies)
Discussion started by: toor13
0 Replies

8. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

9. Linux

Problem with SFTP Command line, "@" in username.

Hi Guys Any help is appreciated very much! I'm trying to use SFTP to an external server using the native SFTP Client in RHEL 6 and 7. I've been given a username on the remote SFTP Server of myemail@myorg.com. I can not seem to escape that @ sign no matter what I do. I've tried these... (16 Replies)
Discussion started by: BG_JrAdmin
16 Replies

10. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies
POSIX_GETPWNAM(3)							 1							 POSIX_GETPWNAM(3)

posix_getpwnam - Return info about a user by username

SYNOPSIS
array posix_getpwnam (string $username) DESCRIPTION
Returns an array of information about the given user. PARAMETERS
o $username - An alphanumeric username. RETURN VALUES
On success an array with the following elements is returned, else FALSE is returned: The user information array +--------+---------------------------------------------------+ |Element | | | | | | | Description | | | | +--------+---------------------------------------------------+ | name | | | | | | | The name element contains the username of the | | | user. This is a short, usually less than 16 char- | | | acter "handle" of the user, not the real, full | | | name. This should be the same as the $username | | | parameter used when calling the function, and | | | hence redundant. | | | | |passwd | | | | | | | The passwd element contains the user's password | | | in an encrypted format. Often, for example on a | | | system employing "shadow" passwords, an asterisk | | | is returned instead. | | | | | uid | | | | | | | User ID of the user in numeric form. | | | | | gid | | | | | | | The group ID of the user. Use the function | | | posix_getgrgid(3) to resolve the group name and a | | | list of its members. | | | | | gecos | | | | | | | GECOS is an obsolete term that refers to the | | | finger information field on a Honeywell batch | | | processing system. The field, however, lives on, | | | and its contents have been formalized by POSIX. | | | The field contains a comma separated list con- | | | taining the user's full name, office phone, | | | office number, and home phone number. On most | | | systems, only the user's full name is available. | | | | | dir | | | | | | | This element contains the absolute path to the | | | home directory of the user. | | | | | shell | | | | | | | The shell element contains the absolute path to | | | the executable of the user's default shell. | | | | +--------+---------------------------------------------------+ EXAMPLES
Example #1 Example use of posix_getpwnam(3) <?php $userinfo = posix_getpwnam("tom"); print_r($userinfo); ?> The above example will output something similar to: Array ( [name] => tom [passwd] => x [uid] => 10000 [gid] => 42 [gecos] => "tom,,," [dir] => "/home/tom" [shell] => "/bin/bash" ) SEE ALSO
posix_getpwuid(3), POSIX man page GETPWNAM(3). PHP Documentation Group POSIX_GETPWNAM(3)
All times are GMT -4. The time now is 06:38 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy