![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to use system function in awk | srikanth_ksv | Shell Programming and Scripting | 3 | 06-18-2009 06:38 AM |
| How to use ${?} and system() function??? | manas6 | UNIX for Dummies Questions & Answers | 1 | 06-09-2008 07:14 AM |
| System() function in <stdlib.h> | someone33 | UNIX for Dummies Questions & Answers | 0 | 05-03-2005 11:11 AM |
| system function in c | collins | High Level Programming | 1 | 11-07-2004 05:48 AM |
| system() function call... | Vishnu | High Level Programming | 1 | 10-15-2002 12:36 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread |
Rating:
|
Display Modes |
|
|
|
||||
|
Question about the system() function in C
Hello all !
Could someone throw some light on whether there's a limit to the number of characters contained in the command string that is passed to the system() call in C. Is it OS dependent? If yes, what are the limits for each? Thanks. |
|
||||
|
The answer in bytes comes from:
Code:
getconf ARG_MAX Edit: Note that ARG_MAX also counts the number of bytes used in environmental variables. So it is argument bytes + env bytes Last edited by jim mcnamara; 11-06-2008 at 08:35 AM.. |
|
||||
|
If the maximum size is even a concern, then you're passing too many arguments.
On my system it is 64K but could be far less in other places. Could this data be passed through a pipe instead, or be split across multiple system() calls? |
|
||||
|
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. |
|
||||
|
if your application is command prompt based, you can always write a script and call that script in system function..
here is an example which may help.. i used it for an application called gnuplot.. system("gnuplot.exe script_name"); script_name is the script that contains all the commands, in my case all the commands used for plotting.. |
![]() |
| Bookmarks |
| Tags |
| system call |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|