LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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 08-31-2010, 06:34 AM   #1
paulux
LQ Newbie
 
Registered: Jan 2008
Posts: 3

Rep: Reputation: 0
Processing a command line literally (without shell quoting)


Hello list,

Does anyone know a method of being able to process the complete and literal command line passed to a shell script ?
I want to have the command line parameters with ALL characters (including meta characters e.g. \$ literally).

So as if there was no shell to substitute or expand parameters nor applying it quoting rules.

Thanks in advance !
 
Old 08-31-2010, 06:38 AM   #2
angel115
Member
 
Registered: Jul 2005
Location: France / Ireland
Distribution: Debian mainly, and Ubuntu
Posts: 542

Rep: Reputation: 79
Did you try single cote "'"
ex: In this example $test will not be taken as a variable but literally
Code:
rm '$test'
if that doesn't meat your requirement can you please give us a relevant example?

Best regards,
Angel

Last edited by angel115; 08-31-2010 at 06:41 AM.
 
Old 08-31-2010, 11:55 PM   #3
paulux
LQ Newbie
 
Registered: Jan 2008
Posts: 3

Original Poster
Rep: Reputation: 0
Hello Angel,

Sorry but this is not what I’m looking for.
I probably didn’t formulate my question clear enough.

I’m aware of the shell concepts of substitution and quoting.
Also when they are applied, and their order.

My issue is to get hold of the whole command line without being processed in any way by the shell.
So all quotes and meta characters sill in place.

For example : # shellscript.sh $LC_ALL some’stange’quoted’paramter’

Within the shecllscript these 2 parameters expand and translate to C and somestangequotedparamter.

What I’m looking for is a way to get hold of that command line the way it was before the shell started.

The parent shell in which the command line is typed forks and exec a new (child) process to execute the command entered.

Is there a way to peek into some location outside the child context to get hold of the raw data from the original command line ?

Regards Paul,
 
Old 09-01-2010, 12:38 AM   #4
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,039

Rep: Reputation: 98
The substitution happens before the script is called, so unless you quote the variables you cannot do what you are after with the current shells.

It is always possible that you could write your own shell in order to do what you are after, but this is not a small amount of work...
 
Old 09-01-2010, 01:26 AM   #5
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by Disillusionist View Post
...
It is always possible that you could write your own shell in order to do what you are after, but this is not a small amount of work...
Probably hacking an existing shell is simpler.
 
Old 09-01-2010, 02:46 AM   #6
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
You have to use escape characters for some stuff. You may still have trouble passing some reserved words, though.
 
  


Reply



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
processing links at the command line. testbot Linux - Newbie 4 09-04-2009 12:16 AM
Audio Processing Tool Command Line To Extract Play Length? lindylex Linux - Software 6 03-10-2009 09:26 PM
LXer: The Linux Command Shell For Beginners: Fear Not The Command Line! LXer Syndicated Linux News 0 12-22-2008 06:30 PM
processing each line of output in Bourne shell? ocicat Programming 11 08-01-2007 01:47 AM
LXer: Don't overlook efficient C/C++ command line processing LXer Syndicated Linux News 0 07-28-2007 08:31 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:58 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration