Sponsored Content
Top Forums UNIX for Advanced & Expert Users Retrieving command line arguments of a particular PID Post 302251085 by redoubtable on Saturday 25th of October 2008 05:04:06 AM
Old 10-25-2008
In Linux, cmdline is to be used as a regular file which splits arguments by nil chars. So, if you have three arguments named 1.foo 2.bar 3.example, then cmdline will have "foo\0bar\0example\0".

Just read cmdline's content and print the arguments by indexing all \0 locations and using pointer arithmetics.

PS: remember that most C string functions stop at '\0' and if you where to have a string like:
Code:
char * foobar = "foo\0bar\0example\0";
printf ("%s\n", foobar); /* this would print foo */
printf ("%s\n", foobar+4); /* this would print bar */
/* pointer arithmetics... */

 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Parsing the command line arguments

Is there a way to get the command line arguments. I am using getopt(3) but if the arguments are more than one for a particular option than it just ignores the second argument. For eg ./a.out -x abc def now abd will be got with -x using getopt "( x : )" and string abc\0def will get stored... (7 Replies)
Discussion started by: jayakhanna
7 Replies

2. Programming

command line arguments

Hi How to pass multi line text as a command line argument to a program. (i.e) ./a.out hi this is sample 0 file1 where hi this is sample should be stored in argv 0 in argv and so on... (3 Replies)
Discussion started by: bankpro
3 Replies

3. UNIX for Dummies Questions & Answers

arguments in command line

Hi all, How many arguments can we pass while testing a prgm at command line.. I encountered an issue while passing 10 arguments. For $10 its taking argument passed for $1 followed by 'zero'. can we pass more than 9 arguments /Is there any other way. Thanks, rrs (6 Replies)
Discussion started by: rrs
6 Replies

4. UNIX for Dummies Questions & Answers

Retrieving PID from a file

Hello I need to retrieve the content of a file in the shell script file(.sh file). I store the Process ID of the a process in file.Only the PID is available in that file. Inside the shell script i want to retireve the content(PID) and need to check for the existence of the Process.Basically... (5 Replies)
Discussion started by: appleforme1415
5 Replies

5. Shell Programming and Scripting

command line arguments

-------------------------------------------------------------------------------- I have this while loop and at the end I am trying to get it to tell me the last argument I entered. And with it like this all I get is the sentence with no value for $1. Now I tried moving done after the sentence... (1 Reply)
Discussion started by: skooly5
1 Replies

6. UNIX for Dummies Questions & Answers

Command line arguments.

I am working on a script wherein i need the user to enter the Build ID for eg:the command line will show enter the build ID Now on entering the build ID it should be assigned to @ARGV. How can this be done.? (1 Reply)
Discussion started by: Varghese
1 Replies

7. UNIX for Dummies Questions & Answers

command line arguments

hi, can someone how to accept command line arguments as a variable using in script? like: ./scriptname arguments by accept arguments, I can use it in my script? thx! (1 Reply)
Discussion started by: ikeQ
1 Replies

8. Shell Programming and Scripting

Command Line Arguments - not working

I am new to the world of Unix and shell scripting and have been trying to get the following simple script to work: #!/bin/bash echo "what is your age?" echo "you are $1 years old"I want to be able to enter my age on the command line, when prompted, and it return the... (1 Reply)
Discussion started by: meursault
1 Replies

9. Shell Programming and Scripting

command line arguments

hi,,,, I want to create a command prompt, for example "prompt>", so my prompt need to handle commands, for example "prompt>cmd", so i want to know how to get arguments for my own commands cmd, i.e. default argc should contain arguments count and argv should point to the argument vector i.e, for... (2 Replies)
Discussion started by: vins_89
2 Replies

10. UNIX for Beginners Questions & Answers

Loop with command line arguments

Ubuntum, Bash version: 4.3.46 Hi, how can I create a loop where the command line arguments change (increase) and every time the number of arguments is different ? ### I have many gene names... that mean gene1=$2, gene2=$3, ...... geneN=$N+1 ### some time the number of gene is 25, other... (7 Replies)
Discussion started by: echo manolis
7 Replies
poolbind(1M)						  System Administration Commands					      poolbind(1M)

NAME
poolbind - bind processes, tasks, or projects or query binding of processes to resource pools SYNOPSIS
/usr/sbin/poolbind -p poolname -e command [arguments]... /usr/sbin/poolbind -p poolname [-i idtype] id... /usr/sbin/poolbind -q pid... /usr/sbin/poolbind -Q pid... DESCRIPTION
The poolbind command allows an authorized user to bind zones, projects, tasks, and processes to pools. With the -e option (see below), it can execute a command you specify, placing the executed command in a specified pool. It can also enable you to query a process to determine which pool a process is bound to. OPTIONS
The following options are supported: -e command [arguments...] Executes command, bound to the pool you specify with -p. -i idtype This option, together with the idlist arguments, specifies one or more processes to which the poolbind command is to apply. The interpretation of idlist depends on the value of idtype. The valid idtype arguments and cor- responding interpretations of idlist are as follows: pid idlist is a list of process IDs. Binds the specified processes to the specified pool. This is the default behavior if no idtype is specified. taskid idlist is a list of task IDs. Bind all processes within the list of task IDs to the specified pool. projid idlist is a list of project IDs. Bind all processes within the list of projects to the specified pool. Each project ID can be specified as either a project name or a numerical project ID. See project(4). zoneid idlist is a list of zone IDs. Bind all processes within the list of zones to the specified pool. Each zone ID can be specified as either a zone name or a numerical zone ID. See zones(5). -p poolname Specifies the name of a pool to which the specified zone, project, tasks, or processes are to be bound. -q pid ... Queries the pool bindings for a given list of process IDs. If the collection of resources associated with the process does not correspond to any currently existing pool, or if there are multiple pools with the set of resources that the process is bound to, the query fails for that particular process ID. -Q pid ... Queries the resource bindings for a given list of process IDs. The resource bindings are each reported on a separate line. EXAMPLES
Example 1 Binding All Processes The following command binds all processes in projects 5 and 7 to the pool web_app: example# /usr/sbin/poolbind -p web_app -i projid 5 7 Example 2 Binding the Running Shell The following command binds the running shell to the pool web_app: example# /usr/sbin/poolbind -p web_app $$ Example 3 Querying the Pool Bindings The following command queries the bindings to verify that the shell is bound to the given pool: example# /usr/sbin/poolbind -q $$ Example 4 Querying the Resource Bindings The following command queries the bindings to verify that the shell is bound to the given resources: example# /usr/sbin/poolbind -Q $$ EXIT STATUS
The following exit values are returned: 0 Successful completion. 1 Requested operation could not be completed. 2 Invalid command line options were specified. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWpool | +-----------------------------+-----------------------------+ |Interface Stability | See below. | +-----------------------------+-----------------------------+ The invocation is Evolving. The output is Unstable. SEE ALSO
pooladm(1M), poolcfg(1M), libpool(3LIB), project(4), attributes(5), zones(5) SunOS 5.11 9 Feb 2005 poolbind(1M)
All times are GMT -4. The time now is 10:08 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy