08-09-2007
how to capture the return value in master script?
Hi,
Here is my program that is returning a DATE:
#! /usr/bin/ksh
db=tcore_dev1
bteq <<end
.logon $password_core
.export report file=$BTEQ_OUTPUT_FILE_$$
select cast(add_months(cast(substr(cast(max(closedate) as varchar(10)),1,8)||'01' as Date),1)-1 as timestamp(0)) from $db.repo
rting;
.export reset
.if errorcode <> 0 then .quit errorcode
end
var=`tail -1 $BTEQ_OUTPUT_FILE_$$ `
rm -f $BTEQ_OUTPUT_FILE_$$
echo $var
return $var
now when I am calling this script from my master script, some dirty data is coming.
Master Script:
#!/usr/bin/ksh
business_date=`getNextCloseDate`
echo Business_date is $business_date
Can anybody help to solve this.
Thanks in advance
--Mahek
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I try to test the carriage return in a variable.
$ LENGTH=`expr $VARIABLE : ".*"` will return the length of the variable. But this doesn't work if $VARIABLE has zero length.
Any help will be well appreciated.
Thanks in advance.
Giovanni (4 Replies)
Discussion started by: gio123bg
4 Replies
2. Shell Programming and Scripting
I am using the following code in my shell script
list=`sqlplus -s $user/$pwd@$dbms<<EOF
WHENEVER SQLERROR EXIT SQL.SQLCODE
set pagesize 0 feedback off verify off heading off echo off
select * from control_tbl
where src_nm=$3
and extrct_nm=$4;
exit SQL.SQLCODE;
EOF`
ERROR=$?... (1 Reply)
Discussion started by: Vikas Sood
1 Replies
3. Shell Programming and Scripting
Hi,
Here is my program that is returning a DATE:
#! /usr/bin/ksh
db=tcore_dev1
bteq <<end
.logon $password_core
.export report file=$BTEQ_OUTPUT_FILE_$$
select cast(add_months(cast(substr(cast(max(closedate) as varchar(10)),1,8)||'01' as Date),1)-1 as timestamp(0)) from $db.repo... (2 Replies)
Discussion started by: mahek_bedi
2 Replies
4. Shell Programming and Scripting
Hi all,
i have written a code to ftp a file from one server to other.The ftp is happeneing successfully,but i am not able to capture the return code,to check if ftp has failed.
plz help me to find out the return code....this is urgent
below is the code i have written... (3 Replies)
Discussion started by: anju
3 Replies
5. Shell Programming and Scripting
Hi All,
My shell script will call a java component with some arguments , the java component returns a string value to the shell script. How to assign the return value to the shell variable.
Here is the sample code.
In my shell script i am calling the java as fallows.
--exporting... (1 Reply)
Discussion started by: rajeshorpu
1 Replies
6. Shell Programming and Scripting
I have a process that copies files from a main storage server to main other servers. We are attempting to speed up the processing and have thought that the best method would be to use concurrent file copying.
What was suggested is that we change from using a simple RCP and waiting for it to... (3 Replies)
Discussion started by: dorrellg
3 Replies
7. Shell Programming and Scripting
I have a K shell script (ksh) that needs to return an email address. A C program was written (prog1) to now access the email address off of an oracle table. The call to the program in the ksh is
prog1 -p parm1
Based on Parm1 the program will read an oracle table and retrieve the email... (2 Replies)
Discussion started by: jclanc8
2 Replies
8. Shell Programming and Scripting
Hi
I am executing database backup via shell script (Korn). The backup log is long, but I would like to capture only the last line so I can send an email if it fails
Example of failed backup (only last 3 lines)
BR0056I End of database backup: bejbofoh.aff 2012-07-26 07.31.21
BR0280I... (7 Replies)
Discussion started by: nimo
7 Replies
9. Shell Programming and Scripting
is it possible to capture the 3 digit return code of ftp commands in a local variable inside a shell script?
Code:
ftp remoteserver << EOFTP
quote USER uid
quote PASS pass
prompt
cd remote_directory
mput file.txt
bye
EOFTP
in the above script, if cd ... (4 Replies)
Discussion started by: Little
4 Replies
10. UNIX Desktop Questions & Answers
I have an application desigend in PHP and MySQl running on apache web server that I is running on a Amazon EC2 server Centos. I want to implement the master-master and master slave replication and high availability disaster recovery on this application database.
For this I have created two... (0 Replies)
Discussion started by: Palak Sharma
0 Replies
LEARN ABOUT SUNOS
endusershell
getusershell(3C) Standard C Library Functions getusershell(3C)
NAME
getusershell, setusershell, endusershell - get legal user shells
SYNOPSIS
#include <unistd.h>
char *getusershell(void);
void setusershell(void);
void endusershell(void);
DESCRIPTION
The getusershell() function returns a pointer to a legal user shell as defined by the system manager in the file /etc/shells. If
/etc/shells does not exist, the following locations of the standard system shells are used in its place:
/bin/bash /bin/csh
/bin/jsh /bin/ksh
/bin/pfcsh /bin/pfksh
/bin/pfsh /bin/sh
/bin/tcsh /bin/zsh
/sbin/jsh /sbin/pfsh
/sbin/sh /usr/bin/bash
/usr/bin/csh /usr/bin/jsh
/usr/bin/ksh /usr/bin/pfcsh
/usr/bin/pfksh /usr/bin/pfsh
/usr/bin/sh /usr/bin/tcsh
/usr/bin/zsh /usr/xpg4/bin/sh
The getusershell() function opens the file /etc/shells, if it exists, and returns the next entry in the list of shells.
The setusershell() function rewinds the file or the list.
The endusershell() function closes the file, frees any memory used by getusershell() and setusershell(), and rewinds the file /etc/shells.
RETURN VALUES
The getusershell() function returns a null pointer on EOF.
BUGS
All information is contained in memory that may be freed with a call to endusershell(), so it must be copied if it is to be saved.
SunOS 5.10 30 Aug 2004 getusershell(3C)