The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
.
google unix.com



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

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rating: Thread Rating: 1 votes, 4.00 average. Display Modes
  #1 (permalink)  
Old 11-06-2008
vsanjit vsanjit is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 5
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.
  #2 (permalink)  
Old 11-06-2008
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,777
The answer in bytes comes from:
Code:
getconf ARG_MAX
it is system dependent

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..
  #3 (permalink)  
Old 11-14-2008
Corona688 Corona688 is offline
Registered User
  
 

Join Date: Aug 2005
Location: Saskatchewan
Posts: 1,960
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?
  #4 (permalink)  
Old 11-14-2008
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,777
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.
  #5 (permalink)  
Old 11-23-2008
npatwardhan npatwardhan is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 135
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..
Closed Thread

Bookmarks

Tags
system call

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 01:18 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0