LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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 05-30-2005, 11:23 AM   #1
mathias1979
LQ Newbie
 
Registered: May 2005
Location: Raleigh, NC
Posts: 7

Rep: Reputation: 0
trouble with quotation marks in c-shell script


Hello,

I'm writing a c-shell script in which I need to obtain the ip address of the person running the script and return it to a variable. I'm using the following command to obtain the ip:

echo $SSH_CLIENT | awk '//{print $1}'

The problem: the only way I'm know to save terminal output as a variable is by doing something like:

set variable = 'command'

So if I put "$SSH_CLIENT | awk '//{print $1}'" in for the command, then there are two sets of single quotation marks, one nested inside the other.

set variable = '$SSH_CLIENT | awk '//{print $1}''

And instead of recognizing them as such, linux assumes the second single quotation closes the first and the command doesn't work.

So how can I write the command so that linux will recognize that second quotation mark as being nested inside the first, as opposed to closing the first so that my command will work properly?

Thanks,
Matt
 
Old 05-30-2005, 11:54 AM   #2
niknah
Member
 
Registered: Dec 2002
Location: In front of a computer
Distribution: UPS, DHL, FedEx
Posts: 466

Rep: Reputation: 38
To get the output from a command is...

set variable = `$SSH_CLIENT | awk '//{print $1}'`

Note: it's the other `, the one next to ~
 
Old 05-30-2005, 12:52 PM   #3
mathias1979
LQ Newbie
 
Registered: May 2005
Location: Raleigh, NC
Posts: 7

Original Poster
Rep: Reputation: 0
Thanks!
 
Old 06-01-2005, 09:49 AM   #4
eddiebaby1023
Member
 
Registered: May 2005
Posts: 378

Rep: Reputation: 33
Why are you writing C-shell scripts? It's a bad enough shell for interactive use, but as a scripting language it's appalling. Use bourne or korn; it's the choice of professionals.
 
  


Reply


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
Execvp With Quotation Marks amitbern Programming 10 11-25-2005 11:28 AM
no quotation marks jdoe9898 Linux - Newbie 1 10-12-2005 04:07 AM
trouble with quotation marks in c-shell script mathias1979 Linux - Newbie 1 05-30-2005 11:16 AM
Quotation Marks Linux / Firefox jjdoll42 Linux - Software 6 04-19-2005 11:13 AM
Quotation marks and strings - in C lazyuser Programming 5 01-25-2005 09:14 AM


All times are GMT -5. The time now is 02:33 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