Visit Jeremy's Blog.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 09-10-2010, 09:17 PM   #1
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.,
appname --option="hello"
translates into
appname --option=hello
(quotes are lost). Here is the output of just such a problem:
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 09:18 PM.
Old 09-10-2010, 09:55 PM   #2
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.


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 07:05 AM
EXPECT/TCL: the "source" command and passing arguments qmqmqm Programming 4 04-02-2009 06:36 PM
Standard commands give "-bash: open: command not found" even in "su -" and "su root" mibo12 Linux - General 4 11-11-2007 11:18 PM
cdrecord command-line parentheses "(" ")" coolingtower Linux - Software 1 10-28-2005 12:49 PM
mutt "Aborted unmodified message." tommyj27 Linux - Software 0 05-16-2003 03:23 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:20 AM.

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