another error level question

Advertisement

Guest

another error level question

I know there are alot of posts on here regarding error level checking but I seem to be missing something. My script transfers a file successfully but I seem to get error level 1 every time. I want to remove the file once it's transfered successfully.
Here's the contents of my batch file:

::::::::::::::::::::::
::PARAMETERS:
::1)linux user
::2)password
::3)server
::4)NT Directory
::5)Filename
::6)Linux Directory (always /transfer/u001/appl/impl)
::7)USER (e.g.fred)
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
echo ::1.%1 2.%2 3.%3 4.%4 5.%5 6.%6 7.%7 > C:\TEMP\mark_for_gen.txt
:: Disable overwrite confirmations that conflict with the previous
echo option confirm off >> C:\TEMP\mark_for_gen.txt
:: Connect using a password
:: open user:password@example.com
:: Connect
echo open %1:%2@%3 >> C:\TEMP\mark_for_gen.txt
:: Change remote directory
echo cd %6 >> C:\TEMP\mark_for_gen.txt
:: Force binary mode transfer
:: option transfer binary or ascii
echo option transfer binary >> C:\TEMP\mark_for_gen.txt
:: PUT localdir\junk
echo PUT %4\%5 %7%5 >> C:\TEMP\mark_for_gen.txt
:: Ensure permissions on transfered file are correct
echo chmod 0755 %7%5 >> C:\TEMP\mark_for_gen.txt
::Close WinSCP
echo close >> C:\TEMP\mark_for_gen.txt
::Exit Command Window
echo exit >> C:\TEMP\mark_for_gen.txt
G:\SYSDEV\DAD\dvs2000_utils\winscp\WinSCP3.exe /console /script=C:\TEMP\mark_for_gen.txt /log=transfer_log.txt
if errorlevel 1 goto error
echo Upload succeeded, removing local file > C:\TEMP\transfer.txt
echo rm %4\%5 >> C:\TEMP\transfer.txt
del %4\%5
close
exit
:error
echo Upload failed, keeping local files > C:\TEMP\transfer.txt
close
exit

##############

I am calling this script within oracle forms, by passing the batch file the 7 parameters:
::1)linux user
::2)password
::3)server
::4)NT Directory
::5)Filename
::6)Linux Directory (always /transfer/u001/appl/impl)
::7)USER (e.g.fred)

The script the above .bat file creates and runs is similar to the following:

::1.<linux_user> 2. <password> 3.<server> 4.G:\sysdev\dad\webforms 5.file.fmb 6./transfer/u001/ybsappl/impl 7.fred
option confirm off
open <linux_user>:<password>@<server>
cd /transfer/u001/ybsappl/impl
option transfer binary
PUT G:\sysdev\dad\webforms\file.fmb fredfile.fmb
chmod 0755 fredfile.fmb
close
exit
################################################################

As I said the script runs, transfers the file but drops into ':error' everytime. The '/log=transfer_log.txt' doesn't seem to function either....

Any ideas?

Thanks

Reply with quote

Advertisement

charlieohampson
Joined:
Posts:
2

Re: another error level question

sorry...I started this thread without logging in.

I've made a bit of progress but still not there yet. I've managed to generate a log file by downloading a more recent version of winscp. However I still seem to get errorlevel 1, as it keeps dropping in to the :error section. I need the script to remove my original file if the copy (or PUT) was successful...which it is. Below is the contents of my logfile. Without understanding that much it seems my script end with error level 0 (Status/error code: 0)....is this correct? thanks

. 2007-04-26 12:26:13.781 --------------------------------------------------------------------------
. 2007-04-26 12:26:13.781 WinSCP Version 4.0.0 (Build 342) (OS 5.0.2195 Service Pack 3)
. 2007-04-26 12:26:13.781 Login time: 26 April 2007 12:26:13
. 2007-04-26 12:26:13.781 --------------------------------------------------------------------------
. 2007-04-26 12:26:13.781 Session name: <linux_user>@<server>
. 2007-04-26 12:26:13.781 Host name: <server> (Port: 22)
. 2007-04-26 12:26:13.781 User name: oracle (Password: Yes, Key file: No)
. 2007-04-26 12:26:13.781 Tunnel: No
. 2007-04-26 12:26:13.781 Transfer Protocol: SFTP (SCP)
. 2007-04-26 12:26:13.781 Ping type: -, Ping interval: 30 sec; Timeout: 15 sec
. 2007-04-26 12:26:13.781 Proxy: none
. 2007-04-26 12:26:13.781 SSH protocol version: 2; Compression: No
. 2007-04-26 12:26:13.781 Agent forwarding: No; TIS/CryptoCard: No; KI: Yes; GSSAPI: No
. 2007-04-26 12:26:13.781 Ciphers: aes,blowfish,3des,WARN,des; Ssh2DES: No
. 2007-04-26 12:26:13.781 SSH Bugs: -,-,-,-,-,-,-,-
. 2007-04-26 12:26:13.781 SFTP Bugs: -,-,-
. 2007-04-26 12:26:13.781 Return code variable: Autodetect; Lookup user groups: Yes
. 2007-04-26 12:26:13.781 Shell: default, EOL: 0
. 2007-04-26 12:26:13.781 Clear aliases: Yes, Unset nat.vars: Yes, Resolve symlinks: Yes
. 2007-04-26 12:26:13.781 Alias LS: No, Ign LS warn: Yes, Scp1 Comp: No
. 2007-04-26 12:26:13.781 Local directory: default, Remote directory: home, Update: No, Cache: Yes
. 2007-04-26 12:26:13.781 Cache directory changes: Yes, Permanent: Yes
. 2007-04-26 12:26:13.781 DST mode: 1
. 2007-04-26 12:26:13.781 --------------------------------------------------------------------------
. 2007-04-26 12:26:13.781 Looking up host "<server>"
. 2007-04-26 12:26:13.796 Connecting to 134.xxx.xx.xx port 22
. 2007-04-26 12:26:13.812 Server version: SSH-1.99-OpenSSH_3.6.1p2
. 2007-04-26 12:26:13.812 We claim version: SSH-2.0-WinSCP_release_4.0
. 2007-04-26 12:26:13.812 Using SSH protocol version 2
. 2007-04-26 12:26:13.812 Doing Diffie-Hellman group exchange
. 2007-04-26 12:26:13.843 Doing Diffie-Hellman key exchange
. 2007-04-26 12:26:14.828 Host key fingerprint is:
. 2007-04-26 12:26:14.828 ssh-rsa 1024 6d:58:f8:4b:b8:9a:15:c9:b2:2e:3d:81:55:b0:ec:4f
. 2007-04-26 12:26:14.828 Initialised AES-256 client->server encryption
. 2007-04-26 12:26:14.828 Initialised HMAC-SHA1 client->server MAC algorithm
. 2007-04-26 12:26:14.828 Initialised AES-256 server->client encryption
. 2007-04-26 12:26:14.828 Initialised HMAC-SHA1 server->client MAC algorithm
! 2007-04-26 12:26:14.828 Using username "<linux_user>".
! 2007-04-26 12:26:14.890 It is a criminal offence, liable to prosecution under the Computer
! 2007-04-26 12:26:14.890 Misuse Act, to access, use or copy any programs or data on this
! 2007-04-26 12:26:14.890 system without authorisation.
! 2007-04-26 12:26:14.890 Passing this point will imply you have read and understood this
! 2007-04-26 12:26:14.890 notice and are an authorised user.
! 2007-04-26 12:26:14.890 Unauthorised users should disconnect immediately.
. 2007-04-26 12:26:14.890 Keyboard-interactive authentication refused
. 2007-04-26 12:26:14.890 Session password prompt (<linux_user>@<server> password: )
. 2007-04-26 12:26:14.890 Using stored password.
. 2007-04-26 12:26:14.890 Sent password
. 2007-04-26 12:26:14.968 Access granted
. 2007-04-26 12:26:14.968 Opened channel for session
. 2007-04-26 12:26:14.968 Started a shell/command
. 2007-04-26 12:26:14.968 --------------------------------------------------------------------------
. 2007-04-26 12:26:14.968 Using SFTP protocol.
. 2007-04-26 12:26:14.968 Doing startup conversation with host.
> 2007-04-26 12:26:14.984 Type: SSH_FXP_INIT, Size: 5, Number: -1
< 2007-04-26 12:26:14.984 Type: SSH_FXP_VERSION, Size: 5, Number: -1
. 2007-04-26 12:26:14.984 SFTP version 3 negotiated.
. 2007-04-26 12:26:14.984 We believe the server has signed timestamps bug
. 2007-04-26 12:26:14.984 We will use UTF-8 strings for status messages only
. 2007-04-26 12:26:14.984 Limiting packet size to OpenSSH sftp-server limit of 262148 bytes
. 2007-04-26 12:26:14.984 Getting current directory name.
. 2007-04-26 12:26:14.984 Getting real path for '.'
> 2007-04-26 12:26:14.984 Type: SSH_FXP_REALPATH, Size: 10, Number: 16
< 2007-04-26 12:26:14.984 Type: SSH_FXP_NAME, Size: 67, Number: 16
. 2007-04-26 12:26:14.984 Real path is '/transfer/u001/sw/dba/oracle'
. 2007-04-26 12:26:14.984 Startup conversation with host finished.
. 2007-04-26 12:26:14.984 Cached directory change via "/transfer/u001/ybsappl/impl" to "/transfer/u001/ybsappl/impl".
. 2007-04-26 12:26:15.000 Getting current directory name.
. 2007-04-26 12:26:15.000 Copying 1 files/directories to remote directory "/transfer/u001/ybsappl/impl"
. 2007-04-26 12:26:15.000 PrTime: Yes; PrRO: Yes; Rght: rw-r--r--; PrR: No (No); FnCs: N; RIC: 01; Resume: S (102400); CalcS: No; Mask: fredfile.fmb
. 2007-04-26 12:26:15.000 TM: B; ClAr: No; ExclM(No):
. 2007-04-26 12:26:15.000 AscM: *.*htm*; *.txt; *.php*; *.cgi; *.c; *.cpp; *.h; *.pas; *.bas; *.tex; *.pl; .htaccess; *.xtml; *.css; *.cfg; *.ini; *.sh; *.xml
. 2007-04-26 12:26:15.000 File: "G:\sysdev\dad\webforms\file.fmb"
. 2007-04-26 12:26:15.000 Copying "G:\sysdev\dad\webforms\file.fmb" to remote directory started.
. 2007-04-26 12:26:15.000 Binary transfer mode selected.
. 2007-04-26 12:26:15.000 Checking existence of file.
> 2007-04-26 12:26:15.000 Type: SSH_FXP_LSTAT, Size: 50, Number: 263
< 2007-04-26 12:26:15.000 Type: SSH_FXP_STATUS, Size: 29, Number: 263
< 2007-04-26 12:26:15.000 Status/error code: 2
. 2007-04-26 12:26:15.000 Checking existence of partially transfered file.
> 2007-04-26 12:26:15.000 Type: SSH_FXP_LSTAT, Size: 59, Number: 519
< 2007-04-26 12:26:15.000 Type: SSH_FXP_STATUS, Size: 29, Number: 519
< 2007-04-26 12:26:15.000 Status/error code: 2
. 2007-04-26 12:26:15.000 Opening remote file.
> 2007-04-26 12:26:15.000 Type: SSH_FXP_OPEN, Size: 75, Number: 771
< 2007-04-26 12:26:15.000 Type: SSH_FXP_HANDLE, Size: 13, Number: 771
> 2007-04-26 12:26:15.000 Type: SSH_FXP_WRITE, Size: 4121, Number: 1286
. 2007-04-26 12:26:27.500 23 skipped SSH_FXP_WRITE, SSH_FXP_READ, SSH_FXP_DATA and SSH_FXP_STATUS packets.
> 2007-04-26 12:26:27.500 Type: SSH_FXP_CLOSE, Size: 13, Number: 4612
< 2007-04-26 12:26:28.468 Type: SSH_FXP_STATUS, Size: 24, Number: 4102
< 2007-04-26 12:26:29.453 Type: SSH_FXP_STATUS, Size: 24, Number: 4358
< 2007-04-26 12:26:29.671 Type: SSH_FXP_STATUS, Size: 24, Number: 4612
< 2007-04-26 12:26:29.671 Status/error code: 0
> 2007-04-26 12:26:29.671 Type: SSH_FXP_RENAME, Size: 104, Number: 4882
< 2007-04-26 12:26:29.671 Type: SSH_FXP_STATUS, Size: 24, Number: 4882
< 2007-04-26 12:26:29.671 Status/error code: 0
> 2007-04-26 12:26:29.671 Type: SSH_FXP_SETSTAT, Size: 62, Number: 1033
< 2007-04-26 12:26:29.671 Type: SSH_FXP_STATUS, Size: 24, Number: 1033
< 2007-04-26 12:26:29.671 Status/error code: 0
. 2007-04-26 12:26:29.671 Changing properties of "fredfile.fmb" (No)
. 2007-04-26 12:26:29.671 - mode: "u+rwx-s,g+rx-ws,o+rx-wt"
> 2007-04-26 12:26:29.671 Type: SSH_FXP_LSTAT, Size: 50, Number: 5127
< 2007-04-26 12:26:29.671 Type: SSH_FXP_ATTRS, Size: 37, Number: 5127
> 2007-04-26 12:26:29.671 Type: SSH_FXP_SETSTAT, Size: 58, Number: 5385
< 2007-04-26 12:26:29.671 Type: SSH_FXP_STATUS, Size: 24, Number: 5385
< 2007-04-26 12:26:29.671 Status/error code: 0
. 2007-04-26 12:26:29.671 Closing connection.


Anonymous wrote:

I know there are alot of posts on here regarding error level checking but I seem to be missing something. My script transfers a file successfully but I seem to get error level 1 every time. I want to remove the file once it's transfered successfully.
Here's the contents of my batch file:

::::::::::::::::::::::
::PARAMETERS:
::1)linux user
::2)password
::3)server
::4)NT Directory
::5)Filename
::6)Linux Directory (always /transfer/u001/appl/impl)
::7)USER (e.g.fred)
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
echo ::1.%1 2.%2 3.%3 4.%4 5.%5 6.%6 7.%7 > C:\TEMP\mark_for_gen.txt
:: Disable overwrite confirmations that conflict with the previous
echo option confirm off >> C:\TEMP\mark_for_gen.txt
:: Connect using a password
:: open user:password@example.com
:: Connect
echo open %1:%2@%3 >> C:\TEMP\mark_for_gen.txt
:: Change remote directory
echo cd %6 >> C:\TEMP\mark_for_gen.txt
:: Force binary mode transfer
:: option transfer binary or ascii
echo option transfer binary >> C:\TEMP\mark_for_gen.txt
:: PUT localdir\junk
echo PUT %4\%5 %7%5 >> C:\TEMP\mark_for_gen.txt
:: Ensure permissions on transfered file are correct
echo chmod 0755 %7%5 >> C:\TEMP\mark_for_gen.txt
::Close WinSCP
echo close >> C:\TEMP\mark_for_gen.txt
::Exit Command Window
echo exit >> C:\TEMP\mark_for_gen.txt
G:\SYSDEV\DAD\dvs2000_utils\winscp\WinSCP3.exe /console /script=C:\TEMP\mark_for_gen.txt /log=transfer_log.txt
if errorlevel 1 goto error
echo Upload succeeded, removing local file > C:\TEMP\transfer.txt
echo rm %4\%5 >> C:\TEMP\transfer.txt
del %4\%5
close
exit
:error
echo Upload failed, keeping local files > C:\TEMP\transfer.txt
close
exit

##############

I am calling this script within oracle forms, by passing the batch file the 7 parameters:
::1)linux user
::2)password
::3)server
::4)NT Directory
::5)Filename
::6)Linux Directory (always /transfer/u001/appl/impl)
::7)USER (e.g.fred)

The script the above .bat file creates and runs is similar to the following:

::1.<linux_user> 2. <password> 3.<server> 4.G:\sysdev\dad\webforms 5.file.fmb 6./transfer/u001/ybsappl/impl 7.fred
option confirm off
open <linux_user>:<password>@<server>
cd /transfer/u001/ybsappl/impl
option transfer binary
PUT G:\sysdev\dad\webforms\file.fmb fredfile.fmb
chmod 0755 fredfile.fmb
close
exit
################################################################

As I said the script runs, transfers the file but drops into ':error' everytime. The '/log=transfer_log.txt' doesn't seem to function either....

Any ideas?

Thanks

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
40,476
Location:
Prague, Czechia

Re: another error level question

Output of the script execution would help.
However I think that the following line causes the problem:
echo ::1.%1 2.%2 3.%3 4.%4 5.%5 6.%6 7.%7 > C:\TEMP\mark_for_gen.txt
It results in "unknown command".

Reply with quote

Advertisement

You can post new topics in this forum