1

I have a ClearCase trigger that runs a .bat file and it works perfectly. What I want to do now is have it run some FTP commands, in my case using WinSCP. I have a command ready in another .bat file which, when run manually, works. When I invoke this .bat file from the .bat launched by the ClearCase trigger, however, it does not work. I have no idea why!

The command in the triggered .bat file is call ftp.bat.

Any ideas? Could it be permissions?

Thanks,

Andrew

Andrew
  • 293
  • 6
  • 14
  • Does it work if you put the winscp command directly in your first file? What about simplifying the second script, with a simple echo in it, to check if that `call ftp.bat` is working? – VonC Feb 08 '13 at 11:47
  • @VonC hi again. Tried everything. No cigar. I echo after the script is run and the echo works. I have also tried transferring the FTP commands into the main .bat. Something is blocking the WinSCP call. I'm trying to figure out what account is used on the ClearCase server once the trigger has fired. – Andrew Feb 08 '13 at 12:50
  • Do you mean you can call a `.bat`, but you cannot have `WinSCP` command anywhere in it? Does calling a `.bat` with just an `echo` works? – VonC Feb 08 '13 at 13:01
  • Did you try `winscp /script=...` (all your `winscp` command being in a text file)? (as in http://winscp.net/eng/docs/guide_automation#script_file) – VonC Feb 08 '13 at 13:02
  • @VonC calling a `.bat` with `echo` works. the ftp `.bat` contains the line `winscp.com /script=sftp_script.txt`. It has an `echo` at the end and it works, just `WinSCP` doesn't run. If I run the script manually it all works, which is why I am thinking about the account that is being used with the trigger. – Andrew Feb 08 '13 at 13:09
  • So I would recommend http://stackoverflow.com/questions/1607271/how-do-you-find-the-current-user-in-a-windows-environment : displaying `%USERNAME%` and `%PATH%` to check who is running the trigger script, and with what `PATH` – VonC Feb 08 '13 at 13:13
  • @VonC `%USERNAME%` returns blank, but the link that you gave provides another suggestion right at the bottom that works, and it is being run by a ClearCase admin account which is an administrator on the system. I was hoping that would give me something to work with, but it doesn't. `%PATH%` doesn't really help since I know that running the script manually works. – Andrew Feb 08 '13 at 13:45
  • Yes, but is the `PATH` the same when run by the trigger? – VonC Feb 08 '13 at 14:00
  • @VonC would that matter since I am using the full path in the script to `winscp.com`? The script is `"C:\Program Files\WinSCP\winscp.com" /script=sftp_script.txt`. – Andrew Feb 08 '13 at 14:37
  • No it wouldn't matter, indeed. – VonC Feb 08 '13 at 15:32
  • @VonC solved by switching to`PSFTP` instead of `WinSCP` and calling with command `echo y | psftp %FTPUSER%@%FTPSERVER% -pw %FTPPASS% -b psftp_script.txt` – Andrew Feb 12 '13 at 08:53
  • Sounds great. I have published that as an answer for more visibility. – VonC Feb 12 '13 at 09:00

1 Answers1

0

As the OP Andrew reports, WinSCP isn't practical when called from another bat.
This would not run:

"C:\Program Files\WinSCP\winscp.com" /script=sftp_script.txt

However, this will, based on psftp (from PuTTY):

 echo y | psftp %FTPUSER%@%FTPSERVER% -pw %FTPPASS% -b psftp_script.txt
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250