How to see the bat log file

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
bkandala
Posts: 9
Joined: 30 Jun 2015 08:42

How to see the bat log file

#1 Post by bkandala » 30 Jun 2015 08:50

Good Morning All,
I created a bat file, the purpose is it uses the winscp script to copy a file from windows to unix. When i execute the bat file the window quikly appears and disappears and nothing happens. Can anyone please tell me the process to create a log file so that i can look into the error messages. Greatlly appreciate your help

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: How to see the bat log file

#2 Post by Squashman » 30 Jun 2015 12:01

Would help to see the batch file you are using.

In general though, make sure ECHO is ON and execute the batch file from the cmd prompt instead of double clicking it with your mouse.

bkandala
Posts: 9
Joined: 30 Jun 2015 08:42

Re: How to see the bat log file

#3 Post by bkandala » 30 Jun 2015 12:13

Thanks Squashman,
The script is below
script option batch on option confirm off open sftp://username:pwd@server:22 -hostkey="ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx" cd /u01/EnvironmentStartup option transfer binary put -preservetime winscp.txt c:\

close exit But when i use "*.txt" insted of winscp.txt its working and copying all the .txt files onto the linux server.

where should i put the ECHO ON?

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: How to see the bat log file

#4 Post by foxidrive » 30 Jun 2015 13:15

If you copy and paste your code using the CODE tags in the forum editor, when you post, then we can see your batch file correctly.


Squashman suggested that you launch the batch file from a cmd prompt
- and that is the advice you should pay attention to because you will see the error messages.

bkandala
Posts: 9
Joined: 30 Jun 2015 08:42

Re: How to see the bat log file

#5 Post by bkandala » 30 Jun 2015 13:17

option batch on
option confirm off
open sftp://username:pwd@server:22 -hostkey="ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx"
cd /u01/EnvironmentStartup
option transfer binary
put -preservetime winscp.txt c:\
close
exit

bkandala
Posts: 9
Joined: 30 Jun 2015 08:42

Re: How to see the bat log file

#6 Post by bkandala » 30 Jun 2015 13:18

foxidrive wrote:If you copy and paste your code using the CODE tags in the forum editor, when you post, then we can see your batch file correctly.


Squashman suggested that you launch the batch file from a cmd prompt
- and that is the advice you should pay attention to because you will see the error messages.


Thanks Foxidrive i did run it from the command prompt and it is doing the same, a window appears and disappears in a second.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: How to see the bat log file

#7 Post by foxidrive » 30 Jun 2015 13:19

bkandala wrote:

Code: Select all

option batch on
 option confirm off
 open sftp://username:pwd@server:22 -hostkey="ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx"
 cd /u01/EnvironmentStartup
 option transfer binary
 put -preservetime winscp.txt c:\
close
exit


That is a script for a third party tool - and not a batch script.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: How to see the bat log file

#8 Post by foxidrive » 30 Jun 2015 13:21

bkandala wrote:Thanks Foxidrive i did run it from the command prompt and it is doing the same, a window appears and disappears in a second.


The exit command at the end is closing the cmd window, but it isn't a batch script.

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: How to see the bat log file

#9 Post by Squashman » 30 Jun 2015 13:31

When I am having problems using a 3rd party utility I usually go straight to the source for help.
Winscp has their own support forum. And they have a category for scripting automation.
http://winscp.net/forum/index.php

bkandala
Posts: 9
Joined: 30 Jun 2015 08:42

Re: How to see the bat log file

#10 Post by bkandala » 30 Jun 2015 13:32

foxidrive wrote:
bkandala wrote:Thanks Foxidrive i did run it from the command prompt and it is doing the same, a window appears and disappears in a second.


The exit command at the end is closing the cmd window, but it isn't a batch script.

Can you please tell what it is? It is doing the sftp part correctly when executed as a bat file

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: How to see the bat log file

#11 Post by foxidrive » 30 Jun 2015 13:37

bkandala wrote:Can you please tell what it is? It is doing the sftp part correctly when executed as a bat file


Are you sure it is doing that?
Is there a batch file called open.bat or open.cmd somewhere?

I don't know which tool you are using. Squashman indicates it is winscp.

bkandala
Posts: 9
Joined: 30 Jun 2015 08:42

Re: How to see the bat log file

#12 Post by bkandala » 30 Jun 2015 13:39

foxidrive wrote:
bkandala wrote:Can you please tell what it is? It is doing the sftp part correctly when executed as a bat file


Are you sure it is doing that?
Is there a batch file called open.bat or open.cmd somewhere?

I don't know which tool you are using. Squashman indicates it is winscp.

when i right click on it ot double click on it , it copies the files from the local c drive to the said path on the linux box, however my problem is if i give a named text file its failing and if i give .*txt its working.
Also my main question was how to add a log file to the bat file so i can see if any errors are logged in there
Thanks

bkandala
Posts: 9
Joined: 30 Jun 2015 08:42

Re: How to see the bat log file

#13 Post by bkandala » 30 Jun 2015 13:40

bkandala wrote:
foxidrive wrote:
bkandala wrote:Can you please tell what it is? It is doing the sftp part correctly when executed as a bat file


Are you sure it is doing that?
Is there a batch file called open.bat or open.cmd somewhere?

I don't know which tool you are using. Squashman indicates it is winscp.

when i right click on it ot double click on it , it copies the files from the local c drive to the said path on the linux box, however my problem is if i give a named text file its failing and if i give .*txt its working.
Also my main question was how to add a log file to the bat file so i can see if any errors are logged in there
Thanks

yes its winscp

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: How to see the bat log file

#14 Post by foxidrive » 30 Jun 2015 13:40

Remove the exit command and try it.

bkandala
Posts: 9
Joined: 30 Jun 2015 08:42

Re: How to see the bat log file

#15 Post by bkandala » 30 Jun 2015 13:44

foxidrive wrote:Remove the exit command and try it.

Tried that , its gives the following error message for each line in the script
'Option' is not recognized as an internal or external command, operable program or a batch file

I used the command at the command prompt:
start c:\test.bat

Post Reply