$HOSTNAME empty while invoking script using SSH


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users $HOSTNAME empty while invoking script using SSH
# 1  
Old 09-15-2011
Question $HOSTNAME empty while invoking script using SSH

Hi,
I am unable to get $HOSTNAME value in a remote script when executed through SSH. Also the scripts hangs and doesnt return to the calling environment.

For instance
Code:
command - 
ssh user1@box2 "cd /var/home/bin ; ./generateScript.sh"

Can any one plese throw light on the issue and also if there is a miss in environment setup or something.

P.S. - When i run the same script on different set of boxes the script works fine.
# 2  
Old 09-15-2011
# 3  
Old 09-15-2011
I didnt get the link you provided... can you explain in brief what can be the workaround?
# 4  
Old 09-15-2011
Code:
ssh user1@box2  "echo \$HOSTNAME"

check whether you can able to get the box2 hostname. If yes, then you can pass it as argument to your script.
# 5  
Old 09-15-2011
Question $HOSTNAME empty while invoking script using SSH

Quote:
Originally Posted by itkamaraj
Code:
ssh user1@box2  "echo \$HOSTNAME"

check whether you can able to get the box2 hostname. If yes, then you can pass it as argument to your script.

I tried it on the box but it still results in empty HOSTNAME Value
# 6  
Old 09-15-2011
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Invoking Application in Shell Script

Hi All, I have a scenario : 1. A list of servers naming server21, server 22, server 23 etc. This list of servers is separate for my environments. Env1 has 3 server Env2 has 5 serves Env3 has 10 servers 2. Each server accesses application through which I want to invoke some method. So... (7 Replies)
Discussion started by: ankur328
7 Replies

2. UNIX for Dummies Questions & Answers

invoking script

hi all, is there a way to run a script upon invoking an application . for eg if i click on mozilla i want a script to run , before runniing mozilla , maybe ask a password or something only then open mozilla (2 Replies)
Discussion started by: mithun1!
2 Replies

3. Shell Programming and Scripting

Invoking a script

I am new to Unix. Could some tell me what are all the possible ways of invoking/executing a script, doesnt matter which shell you are in. Thanks (4 Replies)
Discussion started by: bobby1015
4 Replies

4. Shell Programming and Scripting

Getting hostname using ssh

I am writing a script and need to get the hostname of the remote server in order to zip that file... the syntax in which the file is named is "hostname.html." This is the line I am trying to use ssh $host "/bin/gzip /tmp/`hostname`.html" >> $PATH_TMP/Linux_cfg2html.log but whenever I run it... (26 Replies)
Discussion started by: eponcedeleonc
26 Replies

5. Shell Programming and Scripting

Help with invoking sed from a script

Hello I have a .sh script that needs to take a template and replace zzz in the template file with the user's name. I cannot figure out how to make the following work from my script (works from the command prompt) but not when I put it inside a *.sh script sed 's/xxx/$USER/g' template.conf >... (2 Replies)
Discussion started by: kasiolas
2 Replies

6. Solaris

Solaris 10 allow ssh login with empty passwd

I have turned off PermitEmptyPasswords in sshd_config, but a user with empty passwd (deleted by passwd -d user) can still login without password, why? it is big security concern, linux doesn't have the issue. $ uname -a SunOS 5.10 Generic_118855-14 i86pc i386 i86pc ... (8 Replies)
Discussion started by: honglus
8 Replies

7. Solaris

How to use Secure Shell (SSH) to pass results back to invoking machine

Hi, I am running a script from a client machine X which does "SSH" to around 100 other machines in a farm and invokes a local script on each of those machines. Local script localscript.sh on each of those 100 target machines, does some machine specific function like fetch the specific machine's... (1 Reply)
Discussion started by: waavman
1 Replies

8. Shell Programming and Scripting

returning to the parent shell after invoking a script within a script

Hi everybody, I have a script in which I'm invoking another script which runs in a subshell. after the script is executed I want to return to the parent shell as some variables are set. However i'm unable to return to my original shell as the script which i'm calling inside is invoked in... (5 Replies)
Discussion started by: gurukottur
5 Replies

9. Shell Programming and Scripting

Invoking Shell Script via php

list me commands to invoke a shell script from php once the submit button is clicked in the php page. Requirement is Once a submit button is clicked it should run a script that displays the outcome of the script in a html/php. Please help. Thanks in Advance, BubeshJ (2 Replies)
Discussion started by: bubeshj
2 Replies

10. Shell Programming and Scripting

invoking one shell script from other

hi, i am one day old in shell scritpting. how to invoke one shell script from the other? For eg.i have two shell scripts A.sh and B.sh. Inside A.sh i need to invoke B.sh and the return code of A.sh should be the value returned by B.sh. it would be better if you provide any sample shell... (3 Replies)
Discussion started by: ajay xavier
3 Replies
Login or Register to Ask a Question