简体   繁体   中英

SSMS agent job using scp command to transfer files to sftp is going to loop and not completing

Have tried different approaches to make the SSMs job working with SCP command with perl script. but the job is going into loop with out having a result. PS: The script is working fine with running from command prompt directly.

command used in the perl script:-

$Command = "scp -i D:\File1\RS2\DataFeed\Code\PrivateKey.ppk -s $InternalFile admin@sftp.world.com:$VendorName/$DestFileName";

system command used in perl

system($command);

While running the command directly from windows cmd it is correctly placing file to the SFTP. but while running this perl script from ssms agent job it seems not working and the job is keep running without any results. Any possible leads to the actual errors will be much appreciated

You should:

  • have full path to perl.exe in job's command

  • escape all special characters in interpolated strings for Perl and

  • use full path for scp command since operating system don't know where scp.exe is located (until it in the $PATH):

So

$Command = "scp -i D:\\File1\\RS2\\DataFeed\\Code\\PrivateKey.ppk -s $InternalFile admin\@sftp.world.com:$VendorName/$DestFileName";

Read this: https://www.geeksforgeeks.org/perl-quoted-interpolated-and-escaped-strings/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM