Access files from prev box after SSH to another box

i'm not much of an advanced unix programmer but I'm trying to write a script to access files on box1 after ssh from box 1 to box2. when ssh is invoked in the script i'm getting logged into box2 and losing complete touch with box1 which is normal i guess.

but my main aim with my script is when i connect to box 2 i should be able to access files on box 1 to do my further operations.

my script is still at the basic level, for eg: which looks like this

ssh "$USER"@"$HOST" --> logged into box2 , the following lines are not executing.
ls -lrt ---> this line should execute on box2 but executing on box 1 only after exiting from box 2
echo $HOST
EOF
echo stop

are there any commands to make this possible i.e to view box 1 after ssh and do other functions etc. without exiting from box2

your comments will be very valuable

~Pharos

Unfortunatly ssh just doesn't work like this.

The best way to look at it is to think about what you are trying to achieve. If box2 needs information from box1, why not run the script on box to and have it ssh into box1 to get the info? If this is not possible, gather the information on box1, then ssh over and pass the info to box2.

If you explain what you need done, we can probably give you a hand in setting out the logic for it.

Yes, it's called NFS but has nothing to do with SSH. You share a directory on one server and remotely mount it on the other.

Porter and Dragon, Thanks for your suggestions. I solved the problem now.

Due to confidential reasons i could not provide wht i exactly wanted, but here is an example which i did to solve my problem. Hope it will help others ...just in case

ssh "$USER"@"$HOST" -q -n "ls -lrt;echo $HOST;pwd"

I tried to give everything in a single line to change to my destination dir and later included my logic of scp to do copy from box 1 to box2.

:smiley: