SFTP Coding issue

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?

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.