I try to run a script using SSH. The files are these:
test.sh
#!/bin/sh
export logfile=/home/OprBCIDe/logout.log
export bteqfile=/home/OprBCIDe/test_bteq.btq
echo "Test BTEQ"
bteq < $bteqfile > $logfile 2>&1
test_bteq.btq
.SET ERROROUT STDOUT;
.RUN FILE = /home/OprBCIDe/logon.ini
.EXPORT data file=/home/OprBCIDe/sample.csv
.SET SEPARATOR '|'
SELECT * FROM ds_edw_temp.TEST SAMPLE 100;
.EXPORT reset
.LOGOFF;
.EXIT;
The logon.ini file has the credentials for Teradata.
When I run test.sh file in the local machine, works without problems. But, when I use SSH, the command return this in the logout.log
CLI:Message catalog open failed!: No such file or directory
The file "errmsg.cat" cannot be opened.
There may be problems with your installation.
*** CLI error: -1 Message Not Found!
*** Return code from CLI is: -1
*** Error: Fatal error from CLI.
*** Program exiting!
*** Exiting BTEQ...
*** RC (return code) = 8
I search the problem with errmsg.cat, but I not found nothing specified with Teradata.
EDIT:
I found the solution. Only export COPERR in test.sh with the errmsg.cat location on the remote file system.
Related
I have a bash script that calls another script containing a psql command, i want to stop executing when the psql command fails. The below psql call is to execute a postgres function.
In below script the echo $exitcode always returns 0 even if script calling postgres function returns a error. I want psql command to return right error code, so i can handle it properly in below script.
FirstScript:
list=`sh /opt/dbb_promo_list.sh -60 -30`
ID_LIST=`echo $list |sed 's/[a-z _-]*//g'|sed 's/(.*//g'`
exitcode=$?
echo $exitcode //always returns 0 both in successful and error case, i want it to return corresponding exit code for error, so i can handle it and stop the script.
if [ $exitcode -ne 0 ] ; then
echo "There seems to have errors while running script "
echo "Exit code is : "$exitcode
exit 1
fi
dbb_promo_list.sh : This script contains the following command
psql -U $DB_USERNAME -h $DB_HOST -p $DB_PORT -d $DATABASE -c "SELECT schema.${PROCEDURE}($day_begin,$day_end)"
Error thrown below when calling the above command. Since this error is thrown the psql command shouldnt return exit code 0 but its not the case, it returns 0 even if the postgres function works fine or returns a error like below. I am not sure if there a way to tweak in bash script to recognize a error is thrown
ERROR: function string_agg(numeric, unknown) does not exist
LINE 1: SELECT string_agg(pmotn_id, ',') FROM ppcapr.p...
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
When the sql function fails. It then reports the error on the console, but continues to proceed with executing remainder of the script. But i want the script execution to terminate once the error occurs.
Any suggestions?
I have installed a software named "OMPi" (after make, it generated two executable file ompicc and ompi, and you can use ompicc -x file to do something, and ompi will be called by ompicc).
When I run the command ompicc ~/Documents/example.c in the directory "/my_path/ompi-1.1/compiler" (ompicc is here and ompi is in the sub_path "./ompi/"), an error occurred sh: 1: /my_path/ompi-1.1/compiler/ompi: permission denied. But when I ran the same command in any other directories, the error didn't occur.
sudo chmod 777 -R ompi-1.1 is no use.
I think it may be because the sub_path "./ompi/" get the same name with file ompi. So, I created a directory named "ompi/" in home_path, and then ran the above command. To my surprise, the error didn't occur. It seems that the error only occur when I run the command in the directory: /my_path/ompi-1.1/compiler/
information in terminal
From the looks of it (I have briefly checked ompi's source code), the ompi program is expected by ompicc to be in the same directory. It worked fine after you had created /ompi/ in home directory, because you still had executable of the same name in the same directory as ompicc. It doesn't work in the directory you specified because there's only one ompi there which is a directory.
Line that does the execution in ompicc.c (the constructed command is then ran by a system() call:
sprintf(cmd, "%s%s%s \"%s.pc\" __ompi__%s%s%s%s%s%s%s %s > \"%s\"%s",
usegdb ? "gdb " : "", /* Run gdb instead of running _ompi directly */
RealOmpiName,
usegdb ? " -ex 'set args" : "", /* Pass the arguments */
/* ...further arguments here... */
To confirm that RealOmpiName is 'ompi' i followed the program and
RealOmpiName is traced back to (through external symbol OmpiName)
Makefile.am:
-DOmpiName='"_#PACKAGE_TARNAME#"' \
Which then is used like this (to install the software):
cp -f ompi $(DESTDIR)$(bindir)/_#PACKAGE_TARNAME#
cp -f ompicc $(DESTDIR)$(bindir)/#PACKAGE_TARNAME#cc
I think the installer wouldn't put the two programs together if it didn't require the two to be in the same directory in the first place.
Solution: ompi and ompicc have to be in the same folder/directory.
I am trying to create query explain tables using db2exfmt.
I am using db2 CLP and I am following below steps:
Connect to sample
set current explain mode explain
My query = select * from staff where JOB = 'Sales'
db2 set current explain mode no
db2exfmt -d sample -# 0 -w -1 -g -TIC -n % -s % -o output.txt
After the last step, I am getting this output:
Connecting to the Database.
Connect to Database Successful.
Unable to open output file.
I am not sure why it is not able to open output file. How should I resolve this issue?
It appears that you don't have write access to the C:\Program Files\IBM\SQLLIB\BIN directory, so db2exfmt can't open the output file for writing.
Change to a directory you do have write permissions, or specify a file name with path for the -o option.
I am currently attempting to write a batch file that will open ANSYS Autodyn using MPI on a virtual machine. Whenever I attempt to start the program however, I get the following message;
WARNING: No cached password or password provided.
use '-pass' or '-cache' to provide password
AVS/Express Developer Edition
Version: 8.0 fcs pc10_64
Project: C:\Program Files\ANSYS Inc\v162\aisol\AUTODYN
--- Error detected in: module: OMopen_file ---
can't find file with name: appl and suffix: v or vo in path: C:\Program
Files\ANSYS Inc\v162\aisol\AUTODYN\v;C:\Program Files\ANSYS
Inc\v162\aisol\AUTODYN;.
MPI Application rank 0 exited before MPI_Init() with status -1
The problem is caused by the fact that the path specified in the last paragraph there should be;
C:\Program Files\ANSYS Inc\v162\aisol\AUTODYN\winx64
The problem is that I cannot find the variable that specifies that path, and so I cannot change it. Does anyone know how to solve this problem? Or am I stuck using just one core for the time being?
The batch file code is;
set MPI_ROOT=C:\Program Files\ANSYS Inc\v162\commonfiles\MPI\Platform\9.1.2.1\winx64
"%MPI_ROOT%\bin\mpirun.exe" -mpi64 -prot -e MPI_WORKDIR="C:\Users\umjonesa\AppData\Roaming\Ansys\v162\AUTODYN" -f applfile.txt
PAUSE
That opens the .txt called applfile;
-e MPI_FLAGS=y0 -h localhost -np 1 "C:\Program Files\ANSYS Inc\v162\aisol\AUTODYN\winx64\autodyn.exe"
-h localhost -np 3 "C:\Program Files\ANSYS Inc\v162\aisol\AUTODYN\winx64\adslave.exe"
which should open an autodyn window with one master and three slaves.
root#bt:~# apt-get upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages have been kept back:
smartphone-pentest-framework
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
1 not fully installed or removed.
After this operation, 0B of additional disk space will be used.
Do you want to continue [Y/n]? y
Setting up w3af (1.2-bt2) ...
tar: pybloomfiltermmap-0.2.0.tar.gz: Cannot open: No such file or directory
tar: Error is not recoverable: exiting now
tar: Child returned status 2
tar: Exiting with failure status due to previous errors
/var/lib/dpkg/info/w3af.postinst: line 4: cd: pybloomfiltermmap-0.2.0: No such file or directory
python: can't open file 'setup.py': [Errno 2] No such file or directory
svn: Working copy 'w3af' locked
svn: run 'svn cleanup' to remove locks (type 'svn help cleanup' for details)
dpkg: error processing w3af (--configure):
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
w3af
E: Sub-process /usr/bin/dpkg returned an error code (1)
root
I have copied and pasted the errors i get while updating the packing "smartphone-pentest-framework" above.
What is going wrong and what is the problem?
As you can see "/var/lib/dpkg/info/w3af.postinst: line 4: cd: pybloomfiltermmap-0.2.0: No such file or directory" so simple solution to change the download URL here is the trick they have a bug in their script as the repository moved to https://svn.code.sf.net/p/w3af/code/trunk
so simply edit w3af.postinst file (vi /var/lib/dpkg/info/w3af.postinst)
and replace old url with
https://svn.code.sf.net/p/w3af/code/trunk
save file and then run w3af setup again...