473,399 Members | 3,038 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Using system to pass arguments

158 100+
I need to pass a variable from C witch is a 209 bit char to a php script.

I was thinking that I would use the system function than add the char to the end after the file name.

Any thoughts how to do that.


I know that doesn't work but thats the idea.
Expand|Select|Wrap|Line Numbers
  1.     char buf[209];
  2.     system("php /var/www/htdocs/test.php &buf");
  3.  
  4.  
Jul 23 '08 #1
4 2767
Banfa
9,065 Expert Mod 8TB
That will not work, what you will get passed to the PHP script is the string "&buf".

There is no automatic way to add your data to the php command line, you are going to have to construct a string containing it using functions like sprintf before calling system.
Jul 23 '08 #2
kardon33
158 100+
Ok so i tried doing what you said but no luck yet,

I have successfully put my two char together into one complete one. However when i go and use the system call on php only the string part of the argument is passed.

The argument I am trying to pass is a byte with the first 7 characters letters and that works till that point and the rest are hex but they don't get passed.

Any Ideas?

Expand|Select|Wrap|Line Numbers
  1.  
  2.     int i=0, h=0;
  3.     char  all[238] = "php /var/www/htdocs/test.php ";
  4.  
  5.       while(i < 237)
  6.       {
  7.  
  8.         if(i > 28){ all[i] = buf[h];  h++;  }
  9.                 printf("%d-    %c    -    %x         %d \n", i,  all[i],  all[i],  all[i] );
  10.  
  11.         i++;
  12.       }
  13.  
  14.     system(all);
  15.  
  16.  
Jul 23 '08 #3
Banfa
9,065 Expert Mod 8TB
The argument I am trying to pass is a byte with the first 7 characters letters and that works till that point and the rest are hex but they don't get passed.
They wouldn't, you can only pass text on the command line, you with have to encode your binary data in a text format (may be it's hexidecimal representation) and then the PHP script will have to decode it back into binary.
Jul 23 '08 #4
Banfa
9,065 Expert Mod 8TB
Also you never terminate the string all with a NULL terminator, tobe passed to system it has to be a zero terminated string.
Jul 23 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Didier C | last post by:
Hi! I was wondering if we can pass some arguments to system("cmdline")? E.g in Perl, we can do something like: $dir="/home/cypher"; system("ls $dir"); which would instruct Perl to do an...
2
by: Shailan | last post by:
Hi Im having trouble with the following code that seems to be behave differently when called from the browser as opposed to the command line. The calling script is a cgi that forks, with the...
41
by: Berk Birand | last post by:
Hi, I am just learning about the array/pointer duality in C/C++. I couldn't help wondering, is there a way to pass an array by value? It seems like the only way to do is to pass it by...
5
by: Paul Bergson | last post by:
I have been trying to get a process to start up and run with arguments passed to it. I have gotten close (Thanks to help from this board) but I there is a failure while I'm running this because...
2
by: Randy | last post by:
I am trying to relink some Oracle tables in an Access database via VB.NET and ADOX. I receive the following error when executing the cat.ActiveConnection link "Arguments are of the wrong type,...
2
by: pinkfloydhomer | last post by:
Can I use printf inside a variadic function that I am writing? Like: void print(const char * format,...) { va_list va; va_start(va, format); char buffer; // yeah, I know......
5
by: Michael Sperlle | last post by:
Is it possible? Bestcrypt can supposedly be set up on linux, but it seems to need changes to the kernel before it can be installed, and I have no intention of going through whatever hell that would...
4
by: a_agaga | last post by:
Hi! Do you know different alternatives to convert exceptions in many methods of some wrapper classes. User -Wrapper classes -LibraryClasses -... Wrapper classes catch an exception of only...
29
by: shuisheng | last post by:
Dear All, The problem of choosing pointer or reference is always confusing me. Would you please give me some suggestion on it. I appreciate your kind help. For example, I'd like to convert a...
7
by: bryant | last post by:
Hi all. I am new to ASP and working in Expression Web. The following query displays the information I need in the gridview for a single record. SELECT "OE_HDR"."ORD_NO", "OE_HDR"."CUST_NAM",...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.