LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 09-10-2010, 08:17 PM   #1
cbh2000
LQ Newbie
 
Registered: Sep 2010
Distribution: openSUSE 11.3
Posts: 14

Rep: Reputation: 0
How Get "Unmodified" Command-Line Arguments?


Is there a way to retrieve the arguments in one big string, rather than split into a "char*[]" in C/C++?

It would be nice to get this: "appname --option=value argument argument", rather than "appname", "--option=value", "argument", "argument", etc...

Simply concocting the strings together will not do, since I would like to get the arguments before any OS interaction (i.e.,
Code:
appname --option="hello"
translates into
Code:
appname --option=hello
(quotes are lost). Here is the output of just such a problem:
Code:
bryan@linux-qgp0:~> printargs a "b" ""c""
Argument 0 is: "printargs"
Argument 1 is: "a"
Argument 2 is: "b"
Argument 3 is: "c"
As you can see, the quotation marks are lost...

Last edited by cbh2000; 09-10-2010 at 08:18 PM.
 
Old 09-10-2010, 08:55 PM   #2
rriggs
Member
 
Registered: Mar 2009
Location: Colorado, US
Distribution: Fedora 13, Fedora 14, RHEL6 Beta
Posts: 46

Rep: Reputation: 17
Short answer: no. Long answer: it depends on what shell you use. You can write your own shell that passes the entire command-line as the second arg of execl(). It's not going to work with any other Unix program that requires command-line arguments, so the general utility of that shell will be rather limited.
 
  


Reply

Tags
arguments, c++


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] create a "bookmark" for navigating filesystem from the linux command line jlillywh Linux - Newbie 9 09-18-2009 06:05 AM
EXPECT/TCL: the "source" command and passing arguments qmqmqm Programming 4 04-02-2009 05:36 PM
Standard commands give "-bash: open: command not found" even in "su -" and "su root" mibo12 Linux - General 4 11-11-2007 10:18 PM
cdrecord command-line parentheses "(" ")" coolingtower Linux - Software 1 10-28-2005 11:49 AM
mutt "Aborted unmodified message." tommyj27 Linux - Software 0 05-16-2003 02:23 PM


All times are GMT -5. The time now is 05:42 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration