Sponsored Content
Top Forums Programming Question about the system() function in C Post 302258462 by jim mcnamara on Friday 14th of November 2008 03:56:46 PM
Old 11-14-2008
Corona's point is well taken. One point to add:
Code:
getconf _POSIX_ARG_MAX
4096


So if POSIX mode is taken as a maximum to be usable "everywhere" then we do not have to worry about excessive arguments. See your limits.h file, or sysconf() man page.

A good solution might be to write a script on the fly, then call system(), popen() or even fork()/exec() to run your text - commands string. The point being that a "universal" accepted lowest limit is pretty small, especially if you factor in ENV variables.
 

10 More Discussions You Might Find Interesting

1. Programming

system() function call...

Hi, Though I should check this myself.. but I don't have a cc compiler at this time.. :( When I compile a c program containing say system(myshell.sh).. do the executable require that the actual script myshell.sh to be present whenever it executes? I guess it needs.. otherwise I can just... (1 Reply)
Discussion started by: Vishnu
1 Replies

2. Programming

system function in c

Hai Friends I have used the function system() to execute a command. My requirement is that i have to list the files in a directory applying some wildcard paterns. For example if i want to list *.c files i go with the function system("ls *.c"); and the output gets printed on the monitor.... (1 Reply)
Discussion started by: collins
1 Replies

3. UNIX for Dummies Questions & Answers

FIND function - system wide

Hi, I have a task to search for a file called 'Xstartup' in the whole system because there might be different versions of it which overrite eachother. Can anyone suggest a smart command to run this search ? The machine needs to scan every single folder beginning from root. Please help, I am... (5 Replies)
Discussion started by: DGoubine
5 Replies

4. UNIX for Dummies Questions & Answers

System() function in <stdlib.h>

Hi, guys ,, I want to know the implementation of System() function in C Unix, and its prototype definition: int system(const char * string) in the header file <stdlib.h> ??! please help me ! because that is part of my project !! (0 Replies)
Discussion started by: someone33
0 Replies

5. Shell Programming and Scripting

shell function, system, awk

Hi all, I am calling a shell function within awk using system. I am struggling to get my expected output: #!/bin/sh set -o nounset BEG=44 END=55 shfun() { echo "1|2|3" } export -f shfun typeset -F > /dev/null awk 'BEGIN {OFS="|"; print "'"$BEG"'",system( "shfun"... (5 Replies)
Discussion started by: jkl_jkl
5 Replies

6. UNIX for Dummies Questions & Answers

How to use ${?} and system() function???

Hi All, I am in a process to send the mail automatically with an attachment to bulk users. I have used 'Mailx' and 'Unencode' commands for the same and those worked fine. Please find below the same. X " ( cat /sastemp/body.txt; uuencode test.xls test.xls ) | mailx -s 'testing'... (1 Reply)
Discussion started by: manas6
1 Replies

7. Shell Programming and Scripting

How to use system function in awk

Could any one tell me how to use the system function in awk? I want to use it to print the system date. I have been trying like this : yes |head -1|awk '{ system("date")}' When I execute the above it always returns back to the prompt. Your help would be much appreciated. regards,... (3 Replies)
Discussion started by: srikanth_ksv
3 Replies

8. UNIX for Dummies Questions & Answers

Using system function in C

Hi Guys , I want to use system function in C to do the following work. cp <file1> <file2> and then ><file1> e,g cp \var\log\cpm_cpmd_1.log.1 \var\log\cpm_cpmd_1.log.2 and then >\var\log\cpm_cpmd_1.log.1 1. g_config_info.cpmm_config.cpm_log_path=\var\log\ 2. ... (3 Replies)
Discussion started by: meet123321
3 Replies

9. Shell Programming and Scripting

Help using SYSTEM function in NAWK

I am scanning a file (line by line) for format errors. A line could have multiple errors. Each field in the line is evaluated for errors and sent, along w/ any error messages, to a temporary file. Finally, if any errors were detected, this temporary file is then appended to the errorFile. The... (4 Replies)
Discussion started by: aschera
4 Replies

10. Shell Programming and Scripting

System function in awk

Hello Friends, I have written a script like below, I aimed to move some CDR files (call data record) whose the last field is "1" (NF=1 ) from a spesific directory to a new directory Field Seperator is pipe. If the directory does not exitst i should create it. I will give the script two... (5 Replies)
Discussion started by: EAGL€
5 Replies
SYSCONF(3)						     Linux Programmer's Manual							SYSCONF(3)

NAME
sysconf - get configuration information at run time SYNOPSIS
#include <unistd.h> long sysconf(int name); DESCRIPTION
POSIX allows an application to test at compile or run time whether certain options are supported, or what the value is of certain config- urable constants or limits. At compile time this is done by including <unistd.h> and/or <limits.h> and testing the value of certain macros. At run time, one can ask for numerical values using the present function sysconf(). One can ask for numerical values that may depend on the file system a file is in using the calls fpathconf(3) and pathconf(3). One can ask for string values using confstr(3). The values obtained from these functions are system configuration constants. They do not change during the lifetime of a process. For options, typically, there is a constant _POSIX_FOO that may be defined in <unistd.h>. If it is undefined, one should ask at run time. If it is defined to -1, then the option is not supported. If it is defined to 0, then relevant functions and headers exist, but one has to ask at run time what degree of support is available. If it is defined to a value other than -1 or 0, then the option is supported. Usu- ally the value (such as 200112L) indicates the year and month of the POSIX revision describing the option. Glibc uses the value 1 to indi- cate support as long as the POSIX revision has not been published yet. The sysconf() argument will be _SC_FOO. For a list of options, see posixoptions(7). For variables or limits, typically, there is a constant _FOO, maybe defined in <limits.h>, or _POSIX_FOO, maybe defined in <unistd.h>. The constant will not be defined if the limit is unspecified. If the constant is defined, it gives a guaranteed value, and a greater value might actually be supported. If an application wants to take advantage of values which may change between systems, a call to sysconf() can be made. The sysconf() argument will be _SC_FOO. POSIX.1 variables We give the name of the variable, the name of the sysconf() argument used to inquire about its value, and a short description. First, the POSIX.1 compatible values. ARG_MAX - _SC_ARG_MAX The maximum length of the arguments to the exec(3) family of functions. Must not be less than _POSIX_ARG_MAX (4096). CHILD_MAX - _SC_CHILD_MAX The maximum number of simultaneous processes per user ID. Must not be less than _POSIX_CHILD_MAX (25). HOST_NAME_MAX - _SC_HOST_NAME_MAX Maximum length of a hostname, not including the terminating null byte, as returned by gethostname(2). Must not be less than _POSIX_HOST_NAME_MAX (255). LOGIN_NAME_MAX - _SC_LOGIN_NAME_MAX Maximum length of a login name, including the terminating null byte. Must not be less than _POSIX_LOGIN_NAME_MAX (9). clock ticks - _SC_CLK_TCK The number of clock ticks per second. The corresponding variable is obsolete. It was of course called CLK_TCK. (Note: the macro CLOCKS_PER_SEC does not give information: it must equal 1000000.) OPEN_MAX - _SC_OPEN_MAX The maximum number of files that a process can have open at any time. Must not be less than _POSIX_OPEN_MAX (20). PAGESIZE - _SC_PAGESIZE Size of a page in bytes. Must not be less than 1. (Some systems use PAGE_SIZE instead.) RE_DUP_MAX - _SC_RE_DUP_MAX The number of repeated occurrences of a BRE permitted by regexec(3) and regcomp(3). Must not be less than _POSIX2_RE_DUP_MAX (255). STREAM_MAX - _SC_STREAM_MAX The maximum number of streams that a process can have open at any time. If defined, it has the same value as the standard C macro FOPEN_MAX. Must not be less than _POSIX_STREAM_MAX (8). SYMLOOP_MAX - _SC_SYMLOOP_MAX The maximum number of symbolic links seen in a pathname before resolution returns ELOOP. Must not be less than _POSIX_SYMLOOP_MAX (8). TTY_NAME_MAX - _SC_TTY_NAME_MAX The maximum length of terminal device name, including the terminating null byte. Must not be less than _POSIX_TTY_NAME_MAX (9). TZNAME_MAX - _SC_TZNAME_MAX The maximum number of bytes in a timezone name. Must not be less than _POSIX_TZNAME_MAX (6). _POSIX_VERSION - _SC_VERSION indicates the year and month the POSIX.1 standard was approved in the format YYYYMML; the value 199009L indicates the Sept. 1990 revision. POSIX.2 variables Next, the POSIX.2 values, giving limits for utilities. BC_BASE_MAX - _SC_BC_BASE_MAX indicates the maximum obase value accepted by the bc(1) utility. BC_DIM_MAX - _SC_BC_DIM_MAX indicates the maximum value of elements permitted in an array by bc(1). BC_SCALE_MAX - _SC_BC_SCALE_MAX indicates the maximum scale value allowed by bc(1). BC_STRING_MAX - _SC_BC_STRING_MAX indicates the maximum length of a string accepted by bc(1). COLL_WEIGHTS_MAX - _SC_COLL_WEIGHTS_MAX indicates the maximum numbers of weights that can be assigned to an entry of the LC_COLLATE order keyword in the locale definition file, EXPR_NEST_MAX - _SC_EXPR_NEST_MAX is the maximum number of expressions which can be nested within parentheses by expr(1). LINE_MAX - _SC_LINE_MAX The maximum length of a utility's input line, either from standard input or from a file. This includes space for a trailing new- line. RE_DUP_MAX - _SC_RE_DUP_MAX The maximum number of repeated occurrences of a regular expression when the interval notation {m,n} is used. POSIX2_VERSION - _SC_2_VERSION indicates the version of the POSIX.2 standard in the format of YYYYMML. POSIX2_C_DEV - _SC_2_C_DEV indicates whether the POSIX.2 C language development facilities are supported. POSIX2_FORT_DEV - _SC_2_FORT_DEV indicates whether the POSIX.2 FORTRAN development utilities are supported. POSIX2_FORT_RUN - _SC_2_FORT_RUN indicates whether the POSIX.2 FORTRAN run-time utilities are supported. _POSIX2_LOCALEDEF - _SC_2_LOCALEDEF indicates whether the POSIX.2 creation of locates via localedef(1) is supported. POSIX2_SW_DEV - _SC_2_SW_DEV indicates whether the POSIX.2 software development utilities option is supported. These values also exist, but may not be standard. - _SC_PHYS_PAGES The number of pages of physical memory. Note that it is possible for the product of this value and the value of _SC_PAGESIZE to overflow. - _SC_AVPHYS_PAGES The number of currently available pages of physical memory. - _SC_NPROCESSORS_CONF The number of processors configured. - _SC_NPROCESSORS_ONLN The number of processors currently online (available). RETURN VALUE
If name is invalid, -1 is returned, and errno is set to EINVAL. Otherwise, the value returned is the value of the system resource and errno is not changed. In the case of options, a positive value is returned if a queried option is available, and -1 if it is not. In the case of limits, -1 means that there is no definite limit. CONFORMING TO
POSIX.1-2001. BUGS
It is difficult to use ARG_MAX because it is not specified how much of the argument space for exec(3) is consumed by the user's environment variables. Some returned values may be huge; they are not suitable for allocating memory. SEE ALSO
bc(1), expr(1), getconf(1), locale(1), fpathconf(3), pathconf(3), posixoptions(7) COLOPHON
This page is part of release 3.53 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/. GNU
2013-02-12 SYSCONF(3)
All times are GMT -4. The time now is 02:49 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy