[Solved] Is it possible to use PuTTY psftp.exe to move file from one directory to another?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers [Solved] Is it possible to use PuTTY psftp.exe to move file from one directory to another?
# 1  
Old 06-03-2013
[Solved] Is it possible to use PuTTY psftp.exe to move file from one directory to another?

Hello All,
I am running a script (power shell) from my desktop (Windows). The script needs to sftp a file(using PuTTY psftp.exe ) from my desktop to a server(UNIX server). Then, as a second step, the script needs to move (or copy and delete) this file from one directory on the server (UNIX server) to another directory on the same server (UNIX server).
I have no issues executing the first step. However, I cannot figure out how to execute the second step(move the file) using PuTTY psftp.exe .

Thanks in advanced,
AK,
# 2  
Old 06-03-2013
You should be able to use the rename command.

Code:
$ sftp scott@dns1 << !
> put test1 /tmp
> rename /tmp/test1 /home/scott/testX1
> !
Connected to dns1.
sftp> put test1 /tmp
Uploading test1 to /tmp/test1
test1                                                         100%  117     0.1KB/s   00:00
sftp> rename /tmp/test1 /home/scott/testX1
$
$ ssh scott@dns1
$ pwd
/home/scott
$ ls -l testX1
-rwxr--r-- 1 scott dns1 117 2013-06-03 12:41 testX1

Is it worth asking why you just don't copy it to the target directory in the first place?

Last edited by Scott; 06-03-2013 at 02:47 PM.. Reason: Added code
This User Gave Thanks to Scott For This Post:
# 3  
Old 06-03-2013
Thanks. this is what I was looking for !
BTW, to answer Scott's question, I can not copy the file directly because the process calls for authorization step where the file will be reviewed before being moved to its final destination.

Thanks,
AK,
# 4  
Old 06-03-2013
Ah, OK. Just wondered Smilie Thanks.
This User Gave Thanks to Scott For This Post:
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Windows & DOS: Issues & Discussions

Cant get responsive terminal when I ssh from Windows to Linux using putty.exe

I ssh from Windows to Linux server and execute a few commands. I have ssh keys setup between them and works fine. The commands get executed on the Linux server however I wish to stay on the Linux terminal that was opened by putty.exe. However, the terminal simply does the job and closes. ... (10 Replies)
Discussion started by: mohtashims
10 Replies

2. Shell Programming and Scripting

Shell script cannot create directory and move the file to that directory

I have a script, which is checking if file exists and move it to another directory if then mkdir -p ${LOCL_FILES_DIR}/cool_${Today}/monthly mv report_manual_alloc_rpt_A_I_ASSIGNMENT.${Today}*.csv ${LOCL_FILES_DIR}/cool_${Today}/monthly ... (9 Replies)
Discussion started by: digioleg54
9 Replies

3. Solaris

How to run putty.exe file in server?

Hi, I want to run putty.exe in Solaris server.My main aim is to invoke the putty.exe in Solaris server from a web application(.jsp) deployed in the server so that putty terminal should open. Thanks in advance (11 Replies)
Discussion started by: chaithanyaa
11 Replies

4. UNIX for Dummies Questions & Answers

How to move file from one directory to other of only particular user?

I written unix script where a pdf file generates. But if the script is used by multiple people at a time it generates same pdf with two different owner names and creating a problem with permission while moving the file. is there a way where i can move the file filtering with the user? (4 Replies)
Discussion started by: lakers646
4 Replies

5. UNIX for Dummies Questions & Answers

move a file content to another directory

my script is: /u/user/orginal/:#! /bin/ksh find . -name "aur_prog*" -exec grep -il "error" > test.out #awk command to destination directory exit test.out file contain: ./aur_prog1.log ./aur_prog2.log ... (5 Replies)
Discussion started by: roughwal
5 Replies

6. Solaris

Putty : Change default settings (solved)

Hi, I use to work on solaris via putty and always on session start - i use to increase the font to 14 bold - capture session output to a file my requirement) to make these changes permanent, so that i need not to change the settings everytime i connect via putty please advice. ... (0 Replies)
Discussion started by: saurabh84g
0 Replies

7. Windows & DOS: Issues & Discussions

Batch file to login to putty and list directory

I've created a .bat file with this line: start C:\USERS\Putty\putty.exe -ssh user@server.com -pw password That opens a putty session and logged in it with the user and password i've already specified. But now, I want to enter a simple command like "ls -l" for example.. How can I do that? I've... (3 Replies)
Discussion started by: nirmal.mukundan
3 Replies

8. Windows & DOS: Issues & Discussions

PSFTP/PSCP: remotely deleting directory recursively

Hello, I'm looking for a way to use PSFTP or PSCP, executed from a batch file in Windows, to delete an entire folder and its contents. I can run a script using PSFTP which can use rm or rmdir, but the -rf command doesn't work. Any suggestions on another client to use in the same context, or a... (2 Replies)
Discussion started by: ocdcollector
2 Replies

9. Shell Programming and Scripting

Move the latest or older File from one directory to another Directory

I Need help for one requirement, I want to move the latest/Older file in the folder to another file. File have the datetimestamp in postfix. Example: Source Directory : \a destination Directory : \a\b File1 : xy_MMDDYYYYHHMM.txt (xy_032120101456.txt) File2: xy_MMDDYYYYHHMM.txt... (1 Reply)
Discussion started by: pp_ayyanar
1 Replies

10. Shell Programming and Scripting

Move a file from windows directory to unix directory

Move a file from windows directory to unix directory, is this possible? if it is, can someone help me on this? Thanks! God bless! (1 Reply)
Discussion started by: kingpeejay
1 Replies
Login or Register to Ask a Question