The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
awk to print ' (single quotes) orahi001 UNIX for Dummies Questions & Answers 2 03-11-2008 04:30 PM
grep exclude/find single and double quotes Lindy_so UNIX for Dummies Questions & Answers 4 03-06-2008 09:01 AM
echo using single quotes chella Shell Programming and Scripting 3 10-29-2007 12:54 AM
Single v. double quotes in sed (GNU utilities for Win32 version) daddydojo Shell Programming and Scripting 2 08-05-2007 05:26 PM
Checking Single Quotes in C janemary.a High Level Programming 3 06-07-2007 02:48 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-28-2008
password636 password636 is offline
Registered User
  
 

Join Date: Feb 2008
Location: China
Posts: 6
Double quotes or single quotes when using ssh?

I'm not very familiar with the ssh command. When I tried to set a variable and then echo its value on a remote machine via ssh, I found a problem. For example,

$ ITSME=itsme
$ ssh xxx.xxxx.xxx.xxx "ITSME=itsyou; echo $ITSME"
itsme
$ ssh xxx.xxxx.xxx.xxx 'ITSME=itsyou; echo $ITSME'
itsyou
$

So what was going on here? Which satement was executed on remote machine and which one was on local system? I'm a little confused ....
  #2 (permalink)  
Old 05-28-2008
danmero danmero is offline Forum Advisor  
  
 

Join Date: Nov 2007
Location: 45.48-73.63
Posts: 1,419
Check the links below.
  #3 (permalink)  
Old 05-28-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
Double quotes don't prevent variables from being expanded locally. So the remote host sees "ITSME=itsyou; echo itsme" in the first case.
  #4 (permalink)  
Old 05-29-2008
password636 password636 is offline
Registered User
  
 

Join Date: Feb 2008
Location: China
Posts: 6
Quote:
Originally Posted by era View Post
Double quotes don't prevent variables from being expanded locally. So the remote host sees "ITSME=itsyou; echo itsme" in the first case.
So the two statements: ITSME=itsyou & echo $ITSME are both executed on remote host. But in the case of double quotes, variable will be evaluated first so the argument passed to ssh is actually ITSME=itsyou; echo itsme. While in the case of single quotes, no special characters survive. The argument passed to ssh is ITSME=itsyou; echo $ITSME. Understood, this is really an issue of command-line processing.
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 04:43 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0