0

I want to copy a directory (pscp) from windows server to Linux server The target place name on Linux server has to be new each time.When i run the below command,

> pscp -p -l root
> -pw mypassword -r C:\ProgramFiles\Mybackups\root@linux_server:/root/mywindowsbackups/$(date)

The command substitution $(date) doesn't work. can any one suggest how would i run this ?

nobody
  • 19,814
  • 17
  • 56
  • 77
sudistack
  • 109
  • 1
  • 4

1 Answers1

0

Try the following:

:: This is stripping the `/` and `Day of the Week` from the date
set target_date=%date:/=-%
set target_date=%target_date:* =%

:: Copying the directory to the linux server based on this system's date
pscp -p -l root
-pw mypassword -r C:\ProgramFiles\Mybackups\root@linux_server:/root/mywindowsbackups/%target_date%
Alex
  • 917
  • 5
  • 11
  • hey the above code works , it is creating directory on linux with current date but it is not copying the files from source(windows).I m getting following error > pscp: unable to open /home/sudeep.m/05-18-2014: failure Even this error comes if i specify some random name. But when i run the command once again it is copying the files. – sudistack May 18 '14 at 05:52
  • hey what if i m automating this task. its like i putting this command under.bat file and this .bat file runs from windows task scheduler once in a week :) – sudistack May 18 '14 at 08:25
  • If your question doesn't show the full task, then edit it and put in all the details. – foxidrive May 18 '14 at 08:27