PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Serveur - Sécurité et techniques > comp.security.ssh > How to read a remote environment variable when executing commands using SSH
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
comp.security.ssh SSH secure remote login and tunneling tools.

How to read a remote environment variable when executing commands using SSH

Réponse
 
LinkBack Outils de la discussion
Vieux 03/11/2006, 14h53   #1 (permalink)
kkyzir@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut How to read a remote environment variable when executing commands using SSH

Hello everbody! I want to execute a command to a remote computer using
SSH. Some of arguements provided to the command are read from
environment variables from the local computers, and some arguements are
read from the environment variables of the remote computer. To give an
example:

Environment variables
-------------------------------
Local: NAME="KOSTIS"
Local: HOSTNAME="LOCAL_COMPUTER"
Remote: NAME="HLEKTRA"
Remote: HOSTNAME="REMOTE_COMPUTER"

What I want to do
--------------------------
I want to create a file named MyFile at the remote computer containing
the phrase "KOSTIS is logged to the REMOTE_COMPUTER"

The command I execute
-----------------------------------
ssh -i identity_file -l username "echo $NAME is logged to the
\$REMOTE_COMPUTER > MyFile"

When I type the command at the shell and I run it, it works perfectly.
The problem is that if I type the command inside a script and I execute
the script, the phrase that is written to the remote file is "KOSTIS is
logged to the LOCAL_COMPUTER".

Any would be appreciated!!!!!

  Réponse avec citation
Vieux 03/11/2006, 17h04   #2 (permalink)
Darren Dunham
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: How to read a remote environment variable when executing commands using SSH

kkyzir@gmail.com wrote:
> Hello everbody! I want to execute a command to a remote computer using
> SSH. Some of arguements provided to the command are read from
> environment variables from the local computers, and some arguements are
> read from the environment variables of the remote computer. To give an
> example:


> Environment variables
> -------------------------------
> Local: NAME="KOSTIS"
> Local: HOSTNAME="LOCAL_COMPUTER"
> Remote: NAME="HLEKTRA"
> Remote: HOSTNAME="REMOTE_COMPUTER"


> What I want to do
> --------------------------
> I want to create a file named MyFile at the remote computer containing
> the phrase "KOSTIS is logged to the REMOTE_COMPUTER"


> The command I execute
> -----------------------------------
> ssh -i identity_file -l username "echo $NAME is logged to the
> \$REMOTE_COMPUTER > MyFile"


Perhaps you mean... 'logged to the \$HOSTNAME > MyFile' ?

> When I type the command at the shell and I run it, it works perfectly.
> The problem is that if I type the command inside a script and I execute
> the script, the phrase that is written to the remote file is "KOSTIS is
> logged to the LOCAL_COMPUTER".


Can you show the exact script? Is this sh/bash on both sides?

I can't reproduce your problem. It appears to work the same for me from
the commandline and a script.

# cat /tmp/foo
ssh 10.3.1.44 "echo $SSH_CLIENT --- \$SSH_CLIENT"
# sh /tmp/foo
root@10.3.1.44's password:
10.254.1.6 4244 22 --- 10.3.1.34 1023 22

I'm relatively certain that any issues you have here will be shell
related and not have anything to do with ssh.

--
Darren Dunham ddunham@taos.com
Senior Technical Consultant TAOS http://www.taos.com/
Got some Dr Pepper? San Francisco, CA bay area
< This line left intentionally blank to confuse you. >
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 02h14.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,08471 seconds with 10 queries