How to let pentaho spoon follow the hop 'follow when result false' from a windows batch file - windows

I have an old script that does a number of things, renaming some files. But there error is that if there are no files, it just continues. So I added a hop that is followed on 'result false', and that is executed when there are no files there. This is the script, the first four lines are added by me:
IF NOT EXIST "${DATA_DIR}\*.*" (
ECHO NO FILES DOWNLOADED, ABORTING
ABORT
) ELSE (
IF EXIST "${DATA_DIR}\Bel_Main*.txt" (
RENAME "${DATA_DIR}\Bel_Main*.txt" Bel_Main.txt
)
IF EXIST "${DATA_DIR}\ParcomBE*.txt" (
RENAME "${DATA_DIR}\ParcomBE*.txt" ParcomBE.txt
)
IF EXIST "${DATA_DIR}\BalansBE*.txt" (
RENAME "${DATA_DIR}\BalansBE*.txt" BalansBE.txt
)
)
However, it seems to follow the 'abort path', just because it does not recognize the command 'ABORT'. This is the output:
2022/08/10 17:21:11 - rename files - (stdout) )
2022/08/10 17:21:11 - rename files - (stdout) NO FILES DOWNLOADED, ABORTING
2022/08/10 17:21:11 - rename files - ERROR (version 7.1-SNAPSHOT, build 1 from 2017-08-23 17.37.41 by olbicoserviceuser) : (stderr) 'ABORT' is not recognized as an internal or external command,
2022/08/10 17:21:11 - rename files - ERROR (version 7.1-SNAPSHOT, build 1 from 2017-08-23 17.37.41 by olbicoserviceuser) : (stderr) operable program or batch file.
2022/08/10 17:21:11 - DnB Data Preparation - Starting entry [Abort job]
2022/08/10 17:21:11 - Abort job - ERROR (version 7.1-SNAPSHOT, build 1 from 2017-08-23 17.37.41 by olbicoserviceuser) : Aborting job.
2022/08/10 17:21:11 - DnB Data Preparation - Finished job entry [Abort job] (result=[false])
2022/08/10 17:21:11 - DnB Data Preparation - Job execution finished
2022/08/10 17:21:11 - Spoon - Job has ended.
2022/08/10 17:21:47 - Spoon - Spoon
Now though it seems to work, I wonder if there is a cleverer way to let the 'false' hop to be chosen apart from just making it crash by an unknown command. I tried return false, false, set errorlevel. But I just cannot find the proper way.

'EXIT /B 1'
With the '1' indicating that the result of the batch file was false, so it hops to the 'red arrow' in spoon.

Related

Hive Error on windows - return code 2 from org.apache.hadoop.hive.ql.exec.mr.MapRedTask

When i'm runnning below query on hive installed on windows - "CREATE TABLE emp.filter AS SELECT id,name FROM emp.employee WHERE gender = 'F';
", Im getting following error --
"FAILED: Execution Error, return code 2 from org.apache.hadoop.hive.ql.exec.mr.MapRedTask
2022-08-10 16:17:41,710 ERROR ql.Driver: FAILED: Execution Error, return code 2 from org.apache.hadoop.hive.ql.exec.mr.MapRedTask
MapReduce Jobs Launched:"
Further on checking yarn logs -
So when its launching container, there where the problem is i guess -
""Launching container"
[2022-08-10 16:16:48.142]Container exited with a non-zero exit code 1. Last 4096 bytes of stderr :
'"C:\Users\aksha\Java\jdk1.8.0_202"' is not recognized as an internal or external command,
operable program or batch file."
How can i set it right?
Got it!
After changing "set JAVA_HOME=C:\Users\aksha\Java\jdk1.8.0_202" to
"set JAVA_HOME=C:/Users/aksha/Java/jdk1.8.0_202" in your hadoop-env.cmd file, should launch container/map-red task.

Resolving paths in mingw fails with Data Version Control

I am following the tutorial about Data Version Control using mingw32 on Windows 7.
I am getting very strange error when I try to use run:
$ dvc run -v echo "hello"
Debug: updater is not old enough to check for updates
Debug: PRAGMA user_version;
Debug: fetched: [(2,)]
Debug: CREATE TABLE IF NOT EXISTS state (inode INTEGER PRIMARY KEY, mtime TEXT NOT NULL, md5 TEXT NOT NULL, timestamp TEXT NOT NULL)
Debug: CREATE TABLE IF NOT EXISTS state_info (count INTEGER)
Debug: CREATE TABLE IF NOT EXISTS link_state (path TEXT PRIMARY KEY, inode INTEGER NOT NULL, mtime TEXT NOT NULL)
Debug: INSERT OR IGNORE INTO state_info (count) SELECT 0 WHERE NOT EXISTS (SELECT * FROM state_info)
Debug: PRAGMA user_version = 2;
Running command:
echo hello
/c: /c: Is a directory
Debug: SELECT count from state_info WHERE rowid=1
Debug: fetched: [(1,)]
Debug: UPDATE state_info SET count = 1 WHERE rowid = 1
Error: Traceback (most recent call last):
File "dvc\command\run.py", line 18, in run
File "dvc\project.py", line 265, in run
File "dvc\stage.py", line 435, in run
StageCmdFailedError: Stage 'Dvcfile' cmd echo hello failed
Error: Failed to run command: Stage 'Dvcfile' cmd echo hello failed
Question:
Where does the /c: /c: Is a directory come from? How can I fix it?
My findings
I supposed that it was resolving path to echo, but ech is a builtin.
$ type echo
echo is a shell builtin
I tried also with exit and cd but I am getting the same error.
Calling commands without dvc works fine.
dvc with --no-exec flag works fine, but when later executed with repro gives the same error.
I'm one of the dvc developers. Similar error has affected dvc running on cygwin. We've released a fix for it in 0.20.0. Please upgrade.

Error MSB3073 in postbuild event VS2013

In the process build of a huge enterprise C# VS2013 sometimes I get the error MSB3073 after the in the post build event. Unfortunately all the answers on this topic did not tackle exactly this problem.
The error message is the following:
C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets(4548,5): error MSB3073: The command "#call "D:\TFS\SUV\Dev\2.2.28\DotNet\GUI\Allianz.Vita.Web.SUV\Allianz.Vita.Web.SUV.Post-Build.cmd" D:\TFS\SUV\Dev\2.2.28\DotNet\GUI\Allianz.Vita.Web.SUV\ " exited with code 1073750991.
I was not able to find a criterion to reproduce it sistematically, I only figured out it never happens if I run Clean before Rebuild. Setting verbosity of the MSBuild log to diagnostics did not give me any clue.
The last statement of the cmd file executed in the post build is "SUCCESS", which appears in the log.
Here is the log of a failed build
ERRORLEVEL = 0 (TaskId:2172)
SUCCESS ! (TaskId:2172) ==> end of Allianz.Vita.Web.SUV.Post-Build.cmd file
C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets(4548,5): error MSB3073: The command "#call "D:\TFS\SUV\Dev\2.2.28\DotNet\GUI\Allianz.Vita.Web.SUV\Allianz.Vita.Web.SUV.Post-Build.cmd" D:\TFS\SUV\Dev\2.2.28\DotNet\GUI\Allianz.Vita.Web.SUV\ " exited with code 1073750991.
Done executing task "Exec" -- FAILED. (TaskId:2172)
Here is the log of a successful build:
ERRORLEVEL = 0 (TaskId:2172)
SUCCESS ! (TaskId:2172) ==> end of Allianz.Vita.Web.SUV.Post-Build.cmd file
Done executing task "Exec". (TaskId:2172)
Done building target "PostBuildEvent" in project "Allianz.Vita.Web.SUV.csproj".: (TargetId:3611)
Target "CoreBuild: (TargetId:3612)" in file "C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets" from project "D:\TFS\SUV\Dev\2.2.28\DotNet\GUI\Allianz.Vita.Web.SUV\Allianz.Vita.Web.SUV.csproj" (target "Build" depends on it):
Done building target "CoreBuild" in project "Allianz.Vita.Web.SUV.csproj".: (TargetId:3612)
The error number 1073750991 looks more as a memory pointer that to a coded value. Does the couple of numbers Microsoft.Common.CurrentVersion.targets(4548,5) have a meaning ?
Sorry for the long description, I will be very grateful for any hint.
The cmd file in question basically does this:
nmake.exe %PROJECTDIR%\Allianz.Vita.Web.SUV.Post-Build.mak
echo ERRORLEVEL = %ERRORLEVEL%
and Allianz.Vita.Web.SUV.Post-Build.mak basically is a sequence of xcopy statements as
#xcopy /R /Y .....\FRAMEWORK\Deploy\Allianz.Framework.Security.dll.config .\Bin\
None of them reports (apparently) an error.

Remove usb drive using cli, on success remove turn off the windows

I wondering to make a batch file that have purposed like this :
when a usb drive that ejected on my notebook is succesfully unmount, I want to make my windows is shutdown.
So, I use RemoveDrive.
Assumed, I mounted my flash drive to E, I use this command
RemoveDrive.exe E: -L
it gives me message like this :
Removing 'My drive'(E:)
success
Now, I was wondering to make a batch file (.bat), when success, it execute 'shutdown / s'. if failed, it gives me just a message error. How come ?
Amy help it so appreciated.
Edit :
based this web : FAQ
it said :
0 - successfully removed a device
1 - device identified but not removed
2 - device not found or parameters are invalid
4 - RemoveDrive.exe located on the drive to remove -> temporary copy
created and executed
so this is my code so far :
#ECHO OFF
set def="0"
SET /P uname=Enter the drive (letter:):
IF "%uname%"=="" GOTO Error
RemoveDrive.exe "%uname%" -L
if %ERRORLEVEL% == def
shutdwon /s
else
echo 'Something have problem'
GOTO End
:Error
ECHO Please enter your drive's name!
:End
if success or failed, it still gives me the syntax of command is inicnorrect message
As per if command syntax and explanation in Command-Line Reference:
if %ERRORLEVEL% == def (
shutdown /s
) else (
echo 'Something have problem'
)

Windows copy command return codes?

I would like to test for the success/failure of a copy in a batch file, but I can't find any documentation on what if any errorlevel codes are returned. For example
copy x y
if %errorlevel%. equ 1. (
echo Copy x y failed due to ...
exit /B
) else (
if %errorlevel% equ 2. (
echo Copy x y failed due to ...
exit /B
)
... etc ...
)
I'd opt for xcopy in this case since the error levels are documented (see xcopy documentation, paraphrased below):
Exit code Description
========= ===========
0 Files were copied without error.
1 No files were found to copy.
2 The user pressed CTRL+C to terminate xcopy.
4 Initialization error occurred. There is not
enough memory or disk space, or you entered
an invalid drive name or invalid syntax on
the command line.
5 Disk write error occurred.
In any case, xcopy is a far more powerful solution. The equivalent documentation for copy does not document the error levels.
As an aside, you may want to rethink your use of the %errorlevel% variable. It has unexpected results, at least in some versions of Windows, if someone has explicitly done something silly like:
set errorlevel=22
In those cases, the actual variable will be used rather than grabbing the actual error level. The "normal" way of doing this is (in decreasing order since errorlevel is a "greater than or equal to" check):
if errorlevel 2 (
echo Copy x y failed due to reason 2
exit /B
)
if errorlevel 1 (
echo Copy x y failed due to reason 1
exit /B
)
In addition, if you are running Win7 or Win Server 2008 or later, you should look into Robocopy, which is now the preferred mass-copy solution.
It might also be worth pointing out that xcopy doesn't always return the error code you expect.
For example when trying to copy multiple files with a wildcard but there are no files to copy you expect a return error code of 1 ("No files were found to copy"), but it actually returns 0 ("Files were copied without error")
C:\Users\wilson>mkdir bla
C:\Users\wilson>mkdir blert
C:\Users\wilson>xcopy bla\* blert\
0 File(s) copied
C:\Users\wilson>echo %ERRORLEVEL%
0
I believe Copy only returns 0 for success or 1 for failure.
XCopy has documented return codes:
0 = Files were copied without error.
1 = No files were found to copy.
2 = The user pressed CTRL+C to terminate xcopy.
4 = Initialization error occurred. There is not enough memory or disk space, or you entered an invalid drive name or invalid syntax on the command line.
5 = Disk write error occurred.
There is also one point I would like to emphasize: xcopy as well as robocopy can only copy files, but they can't rename them.
While looking at the original situation (copy x y, which looks like a rename to me), I have the impression that the copy command still is the only one suitable for this purpose.
Error# Description
0 No error
1 Not owner
2 No such file or directory
3 Interrupted system call
4 I/O error
5 Bad file number
6 No more processes
7 Not enough core memory
8 Permission denied
9 Bad address
10 File exists
11 No such device
12 Not a directory
13 Is a directory
14 File table overflow
15 Too many open files
16 File too large
17 No space left on device
18 Directory not empty
999 Unmapped error (ABL default)

Resources