aspose file tools*
The moose likes Linux / UNIX and the fly likes Change the path on remote server and export the current directory in a variable from local machine Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "Change the path on remote server and export the current directory in a variable from local machine" Watch "Change the path on remote server and export the current directory in a variable from local machine" New topic
Author

Change the path on remote server and export the current directory in a variable from local machine

Ragupathirajan Venkatesan
Ranch Hand

Joined: Aug 18, 2010
Posts: 62
Dear All,

I am connecting the remote machine via ssh to execute one script in that server. My script in some other path than the default one, hence changing the path using cd command and executing the sctipt. This works fine. Now I need to export the current directoty of the remote server after ececuting the cd command during ssh.

Here is the sample code that I am trying.

sss test@remoteserver.com
cd /dir/test/script
./test.sh

To run the test.sh file successfuly, I need to assign the /dir/test/script/ value to one variable from the above script itself. I dont have rights to change the test.sh file itself on remote server as it is provided by thirdparty.
This is how I am trying

sss test@remoteserver.com
cd /dir/test/script
log_dir=`pwd` (Also tried like log_dir='/dir/test/script/')
export $log_dir
echo $log_dir
./test.sh

But my echo is not getting printed. Any suggestion.

Thanks in Advance
Carles Gasques
Ranch Hand

Joined: Apr 19, 2013
Posts: 199
    
    1
Hi,

5 seconds test on my cygwin terminal seems to work properly


Best regards,
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16142
    
  21

1. It's "export logdir", not "export $logdir".

2. Shell variable names conventionally are all upper-case. So instead of "logdir", "LOGDIR" is the preferred usage.


Customer surveys are for companies who didn't pay proper attention to begin with.
Ragupathirajan Venkatesan
Ranch Hand

Joined: Aug 18, 2010
Posts: 62
Thanks a lot !!!
 
Consider Paul's rocket mass heater.
 
subject: Change the path on remote server and export the current directory in a variable from local machine