How do I get KDiff3 to automatically do a 3-way merge such that it shows no UI? Ideally, if it succeeds, it returns success, and if it can't (it needs manual merging), it returns an error code.
Everything I've read seems to imply that the following should work:
"c:\Program Files\KDiff3\kdiff3.exe" --auto base.txt src.txt tar.txt -o merge.txt
However, it doesn't. When I run it, a message box pops up that says:
Total number of conflicts: 3
Nr of automatically solved conflicts: 3
Nr of unsolved conflicts: 0
How do I get it to run without this popup, and no GUI at all if it fails?
I figured it out. I need to add a "--cs" and "ShowInfoDialogs=0" to the command line. So this:
"c:\Program Files\KDiff3\kdiff3.exe" --auto base.txt src.txt tar.txt -o merge.txt
...becomes this:
"c:\Program Files\KDiff3\kdiff3.exe" --auto base.txt src.txt tar.txt -o merge.txt --cs "ShowInfoDialogs=0"
...and now it works.
Related
I have a data set with multiple netcdf files with the same variables and structure, though the grid shifts in the time series periodically. I am working on simply remapping one file to another. However, the following command when run with the linked data files, 2016090618.nc and 2016090712.nc:
ncremap -d 2016090618.nc -i 2016090712.nc -o outputfile_2016090712.nc
results in the following error:
Input #00: /content/drive/MyDrive/2016090712.nc
Grid(src): /tmp/ncremap_tmp_grd_src.nc.pid198744
Grid(dst): /tmp/ncremap_tmp_grd_dst.nc.pid198744
Map/Wgt : /tmp/ncremap_tmp_map_nco_nco_con.nc.pid198744
ncks: ERROR nco_rgr_wgt() reports frc_out == frac_b contains all zeros
ncremap: ERROR Failed to horizontally regrid. cmd_rgr[0] failed. Debug this:
ncks -O -t 2 --no_tmp_fl --gaa remap_script=ncremap --gaa remap_command="'/usr/bin/ncremap -d 2016090618.nc -i 2016090712.nc -o outputfile_2016090712.nc'" --gaa remap_hostname=e3d132815114 --gaa remap_version=4.9.1 --hdr_pad=10000 --rgr lat_nm_out=lat#lon_nm_out=lon --map="/tmp/ncremap_tmp_map_nco_nco_con.nc.pid198744" "/content/drive/MyDrive/Projects/20220014_CMM3/RDRS_input_data/CaPA_coarse/2016090712.nc" "outputfile_2016090712.nc"
This is being run in Google Colab with nco installed (thus the /content/drive/MyDrive path, and I omitted the exclamation mark from the ncremap command above).
I have tried to unpack the data with the -U flag and looked at the -R argument to no avail.
Incidentally, the cdo command below works fine to remap the file, but results in changes of the variable organization and naming that doesn't work well for my purposes, so I am trying to solve this with nco.
cdo remapbil,2016090618.nc 2016090712.nc outputfile_2016090712.nc
The good news is that newer versions of NCO do not die like you show above, so you might try upgrading to NCO 5.1.4:
zender#spectral:~/Downloads$ ncremap --version
ncremap, the NCO regridder and grid, map, and weight-generator, version 5.1.5-alpha02 "Champignons"
...
zender#spectral:~/Downloads$ ncremap -d 2016090618.nc -i 2016090712.nc -o outputfile_2016090712.nc
Input #00: /Users/zender/Downloads/2016090712.nc
Grid(src): /var/folders/ct/rzzvxlqn4_3f9cr8wgn2pm480000gn/T/ncremap_tmp_grd_src.nc.pid33012
Grid(dst): /var/folders/ct/rzzvxlqn4_3f9cr8wgn2pm480000gn/T/ncremap_tmp_grd_dst.nc.pid33012
Map/Wgt : /var/folders/ct/rzzvxlqn4_3f9cr8wgn2pm480000gn/T/ncremap_tmp_map_nco_nco_con.nc.pid33012
zender#spectral:~/Downloads$
The bad news is that the input files, and thus the output file, all contain NaN values. NCO does not like NaN for reasons described here. So I cannot tell whether it works as intended. BTW, if you want bilinear rather than conservative regridding, then use ncremap --alg_typ=bilinear ....
I created a batch script for windows that I use for mux mkv files.
When launch this command:
ffprobe -v 0 -select_streams s -show_entries stream=index:disposition=default -of compact=nk=0 file.mkv | findstr disposition:default=1
Output is:
stream|index=3|disposition:default=1
How can filter and print only number "3" and put it in a variable?
I submit a new command that simplify output:
ffprobe -v 0 -select_streams s -show_entries stream=index:disposition=forced:stream_tags=language -of csv=nk=1:p=0 file.mkv | FINDSTR /C:"1,ita"
Output is:
3,1,ita
"3" is track id, "1" is forced flag, "ita" is track language. To create a variable that contains only the track id (e.g. 3) to be inserted in a mkvmerge command, I ran this command:
FOR /F "delims=, tokens=1" %%# IN ('ffprobe -v 0 -select_streams s -show_entries stream=index:disposition=forced:stream_tags=language -of csv=nk=1:p=0 file.mkv ^| FINDSTR /C:"1,ita"') DO SET subid=%%#
But nothing happens! Mkvmerge report this error: Error: Invalid track ID or language code in '-s '.
I don't really know where the mistake is!
Batchfile approach
You need to execute your command inside a for statement inside a batch file to be able to capture the output lines and process them further. Check for /? on the command line and the part with for /f and learn about "usebackq".
The key point is, that you need to escape several special characters from your command, if it is executed in the for statement and not on the command line prompt directly.
Try getting this piece to work and post your solution as update to your answer if you like. Then we can get to the second part of extracting the number.
I have a test script I'm running that generates some errors,shown below, I expect these errors. Is there anyway I can prevent them from showing on the screen however? I use the
$ write sys$output
to display if there is an expected error.
I tried to use
$ DEFINE SYS$ERROR ERROR.LOG
but this then changed my entire error output log to this, if this is the correct way to handle it can I unset this at the end of my script somehow?
[error example]
%DCL-E-OPENIN, error opening TEST$DISK:[AAA]NOTTHERE.TXT; as input
-RMS-E-FNF, file not found
%DCL-E-OPENIN, error opening TEST$DISK:[AAA]NOTTHERE.TXT; as input
-RMS-E-FNF, file not found
%DCL-W-UNDFIL, file has not been opened by DCL - check logical name
DEFINE/USER creates a logical name that disappears when the next image exits.
So if you use that just before a command just to protect that command, then fine.
Otherwise I would prefer SET MESSAGE to control the output.
And of course yoy want to grab $STATUS and verify it after the command for success or for the expected error, reporting any unexpected error.
Better still... if you expect certain error conditions to occur,
then why not test for them?
For example:
$ file = F$SEARCH("TEST$DISK:[AAA]NOTTHERE.TXT")
$ IF file.NES."" THEN TYPE 'file'
Cheers,
Hein
To suppress Error message inside a script. try this command
$ DEFINE/USER SYS$ERROR NL:
NL: is a null device, so you don`t see any error messages displayed on your terminal.
good luck
This works interactively and in batch.
$ SET MESSAGE /NOTEXT /NOSEV /NOFAC /NOID
$ <DCL_Command>
$ SET MESSAGE /TEXT /SEV /FAC/ ID
I am writing a script that will copy Valgrind onto whatever shelf that we enter on the command line. The syntax is as follows:
vgrindCopy [shelf number]
For some reason, the files will copy over without any issue, but after the copy completes the follow error is observed:
bad spawn_id (process died earlier?)
while executing
"expect "#""
Here is a copy of the relevant code:
function login_shelf {
expect -c "
set timeout 15
spawn $1
expect \"password:\"
send \"$PW\r\"
expect \"#\"
sleep 1
exit
"
}
# login and make the valgrind directory at /sfs/software/shelf/current
set -- /opt/swe/tools/ext/gnu/valgrind-3.7.0/i686-linux2.6/lib/valgrind/*
login_shelf "/opt/corp/projects/shelftools/bin/app rsync -Lau $* $shelf:/shelf/valgrind"
After playing around with the code, I found that if I remove the line "expect \"#\"", then the program doesn't copy any of the files over anymore. What odd as well is that I'm seeing the issue when I run the script, but a co-worker is not.
Has anyone had a similar issue and determined the cause? Any help would be greatly appreciated as always!
Your code is spawning the rsync and at the expect \"#\" is waiting for rsync to output a #, which it never does, so it exits and expect reports the error.
When you remove the expect \"#\" the expect script exits, terminating the rsync.
Instead of expect \"#\" you should wait for rsync to exit:
expect eof
wait
What is the meaning of return value 127 from $? in UNIX.
Value 127 is returned by /bin/sh when the given command is not found within your PATH system variable and it is not a built-in shell command. In other words, the system doesn't understand your command, because it doesn't know where to find the binary you're trying to call.
Generally it means:
127 - command not found
but it can also mean that the command is found,
but a library that is required by the command is NOT found.
127 - command not found
example: $caat
The error message will
bash:
caat: command not found
now you check using echo $?
A shell convention is that a successful executable should exit with the value 0. Anything else can be interpreted as a failure of some sort, on part of bash or the executable you that just ran. See also $PIPESTATUS and the EXIT STATUS section of the bash man page:
For the shell’s purposes, a command which exits with a zero exit status has succeeded. An exit status
of zero indicates success. A non-zero exit status indicates failure. When a command terminates on a
fatal signal N, bash uses the value of 128+N as the exit status.
If a command is not found, the child process created to execute it returns a status of 127. If a com-
mand is found but is not executable, the return status is 126.
If a command fails because of an error during expansion or redirection, the exit status is greater than
zero.
Shell builtin commands return a status of 0 (true) if successful, and non-zero (false) if an error
occurs while they execute. All builtins return an exit status of 2 to indicate incorrect usage.
Bash itself returns the exit status of the last command executed, unless a syntax error occurs, in
which case it exits with a non-zero value. See also the exit builtin command below.
It has no special meaning, other than that the last process to exit did so with an exit status of 127.
However, it is also used by bash (assuming you're using bash as a shell) to tell you that the command you tried to execute couldn't be executed (i.e. it couldn't be found). It's unfortunately not immediately deducible though, if the process exited with status 127, or if it couldn't found.
EDIT:
Not immediately deducible, except for the output on the console, but this is stack overflow, so I assume you're doing this in a script.
If you're trying to run a program using a scripting language, you may need to include the full path of the scripting language and the file to execute. For example:
exec('/usr/local/bin/node /usr/local/lib/node_modules/uglifycss/uglifycss in.css > out.css');
This error is also at times deceiving. It says file is not found even though the files is indeed present. It could be because of invalid unreadable special characters present in the files that could be caused by the editor you are using. This link might help you in such cases.
-bash: ./my_script: /bin/bash^M: bad interpreter: No such file or directory
The best way to find out if it is this issue is to simple place an echo statement in the entire file and verify if the same error is thrown.
If the IBM mainframe JCL has some extra characters or numbers at the end of the name of unix script being called then it can throw such error.
In addition to the given answers, note that running a script file with incorrect end-of-line characters could also result in 127 exit code if you use /bin/sh as your shell.
As an example, if you run a shell script with CRLF end-of-line characters in a UNIX-based system and in the /bin/sh shell, it is possible to encounter some errors like the following I've got after running my script named my_test.sh :
$ ./my_test.sh
sh: 2: ./my_test.sh: not found
$ echo $?
127
As a note, using /bin/bash, I got 126 exit code, which is in accordance with gnu.org documentation about the bash :
If a command is not found, the child process created to execute it returns a status of 127. If a command is found but is not executable, the return status is 126.
Finally, here is the result of running my script in /bin/bash :
arman#Debian-1100:~$ ./my_test.sh
-bash: ./my_test.sh: /bin/bash^M: bad interpreter: No such file or directory
arman#Debian-1100:~$ echo $?
126
go to C:\Program Files\Git\etc
open gitconfig with notepad
change
[core]
autocrlf = true
To
[core]
autocrlf = false