I'm looking for a way to call system commands with variable parameters
within a Unix environment. Sort of like system() but i need to be
able to pass variable parameters....so I guess it would kind of look
like this:
system("command -%s -%s", parameter1, parameter2);
I've tried the above and it doesn't work when compiled with GCC.
Thanks. 4 9841
"shaggystyle" <sh*********@hotmail.com> wrote in message
news:6d**************************@posting.google.c om... I'm looking for a way to call system commands with variable parameters within a Unix environment. Sort of like system() but i need to be able to pass variable parameters....so I guess it would kind of look like this:
system("command -%s -%s", parameter1, parameter2);
I've tried the above and it doesn't work when compiled with GCC. Thanks.
Hello
Use sprintf()
char temp[512];
sprintf(temp, "command -%s -%s", parameter1, parameter2);
system((char *)temp);
However this was not a C++ question.
--
Elias
On Wed, 18 Feb 2004 18:05:32 +0200 in comp.lang.c++, "lallous"
<la*****@lgwm.org> was alleged to have written: Use sprintf()
char temp[512]; sprintf(temp, "command -%s -%s", parameter1, parameter2); system((char *)temp);
However this was not a C++ question.
std::ostringstream cmd;
cmd << "command -" << parameter1 << " -" << parameter2;
system(cmd.str().c_str());
There, now it was a C++ question. :-)
In article <c1*************@ID-161723.news.uni-berlin.de>,
"lallous" <la*****@lgwm.org> wrote: "shaggystyle" <sh*********@hotmail.com> wrote in message news:6d**************************@posting.google.c om... I'm looking for a way to call system commands with variable parameters within a Unix environment. Sort of like system() but i need to be able to pass variable parameters....so I guess it would kind of look like this:
system("command -%s -%s", parameter1, parameter2);
I've tried the above and it doesn't work when compiled with GCC. Thanks. Hello
Use sprintf()
char temp[512];
What if the command plus it's parameters is longer than 511 characters?
Use ostringstream instead.
sprintf(temp, "command -%s -%s", parameter1, parameter2); system((char *)temp);
This cast is completely redundant.
David Harmon <so****@netcom.com> wrote in message news:<40****************@news.west.earthlink.net>. .. On Wed, 18 Feb 2004 18:05:32 +0200 in comp.lang.c++, "lallous" <la*****@lgwm.org> was alleged to have written:Use sprintf()
char temp[512]; sprintf(temp, "command -%s -%s", parameter1, parameter2); system((char *)temp);
However this was not a C++ question.
std::ostringstream cmd; cmd << "command -" << parameter1 << " -" << parameter2; system(cmd.str().c_str());
There, now it was a C++ question. :-)
Thanks for the tip!
--
Elias This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Bruno Alexandre |
last post by:
Hi guys,
withou using SP, I want to be able to add a Parameter to the SQL Query and
retrive the Recordset so I can use the Paging property under the recorset
object.... how can I do this?
I'm...
|
by: Nashat Wanly |
last post by:
HOW TO: Call a Parameterized Stored Procedure by Using ADO.NET and
Visual C# .NET
View products that this article applies to.
This article was previously published under Q310070
For a Microsoft...
|
by: Brian Conway |
last post by:
Hope someone can help. I am trying to get a submit button working and
getting this error now System.InvalidCastException: Object must implement
IConvertible. This is showing up on the...
|
by: JLK |
last post by:
I'm having a bit of a time with the following code. I can script this
real easy in Bash but I'm trying to practice my C++:
*******************************************************
#include...
|
by: Chris |
last post by:
Hello everyone
I want to call a DB2 7.2 stored procedure via ADO in VC++ 7.1
It has 4 parameters, the 1st and the 4th are OUTPUT and the others are INPUT
params.
My code looks like this:...
|
by: Steven K |
last post by:
Hello,
With ASP, I could indicate that a variable was a stored procedure with
parameters by using "adcmdStoredProc", and set the data variable with one
line using the Execute command (cnnSearch...
|
by: ravi |
last post by:
Hi,
i am a c++ programmer,
now i want to learn programming in c also.
so can anybody explain me the difference b/w call by reference and
call by
pointer (with example if possible).
|
by: C++ Newbie |
last post by:
Hi,
Why doesn't the following C++ program echo the value of 97? If you
manually "head -3 temp.txt | tail -1" the temp.txt file, you will get
97. Use it in a system call, and it doesn't work.
...
|
by: ashitpro |
last post by:
Writing System Call Wrappers in User Space.
Recently I saw a post in Linux/Unix section to know the user who deleted the file in linux. Currently there is nothing in linux which could achieve...
|
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
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
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...
|
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...
|
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,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
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: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| |