Scenario :
when a file is uploaded to a SFTP account I would like to trigger a "File Uploaded "event and execute command action and use the build-in Servu- $FileName variable to pass the name of a file
and replace a existing string in another File.
I use the following command line parameters
-noprofile -executionpolicy unrestricted -noninteractive -Command cat c:\testing\static.txt |%{$_-replace "random",$FileName} > C:\testing\define.txt
The above command works perfectly if i run it directly in PowerShell, but not in Serv-U
The contents of static.txt is :
$client = "random"
So If the filename of the file which is uploaded is tony.pdf, then the contents of define.txt should be
$client = "tony.pdf"
Unfortunately I'm getting this :
$client = ""
I've tried pasting the command and parameters in a PowerShell script and then running the script in serv-u however it doesn't work it loses the variable
.
I think the issue has to do with special characters or parenthesis in Servu, because I've tested the following command and it works:
Command echo "$FileName" >> c:\testing\input.txt
Please help
Tony