# SFTP Coding issue

**URL:** <https://community.unix.com/t/sftp-coding-issue/294276>\
**Category:** UNIX for Dummies Questions & Answers\
**Created:** [August 26, 2011, 4:50pm UTC](https://community.unix.com/t/sftp-coding-issue/294276 "2011-08-26T16:50:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![krishna87](https://community.unix.com/letter_avatar/krishna87/32/6_22734026db12803ebb3e059622ac3534.png) [@krishna87](https://community.unix.com/u/krishna87)\
**Post date:** [August 26, 2011, 4:50pm UTC](https://community.unix.com/t/sftp-coding-issue/294276/1 "2011-08-26T16:50:59Z")

</div>

Hi

I am trying to SFTP file from source\_path to Destination\_path. For this I wrote the below script:

cd $source\_path

sftp $user\_name@$target\_server  
pwd  
cd $destination\_path  
put $filename

After connecting to target\_server via sftp, pwd should be target server home path but it is $source\_path.

Can anyone explain this?

---

<div class="post-metadata">

**Author:** ![jgt](https://community.unix.com/user_avatar/community.unix.com/jgt/32/10703_2.png) [@jgt](https://community.unix.com/u/jgt)\
**Post date:** [August 26, 2011, 5:49pm UTC](https://community.unix.com/t/sftp-coding-issue/294276/2 "2011-08-26T17:49:59Z")

</div>

Is the home directory of the user the same on both the source and target machines?  
Try cd /tmp, before running your script.  
I tried your example, and the results I got were what you expected.
