Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sybase bcp doesn't work with crontab 1

Status
Not open for further replies.

fabthecop

IS-IT--Management
Sep 14, 2009
5
IT
Hello,

I have a sybase installation with SSH access (no root no sudoer).
I wrote a simple bash script for bulk copying out a table into a file.

If I execute the script from the shell, everything works fine. If I put the script in my crontab, the job returns "Server name not found in interface file".

Ok, I thought perhaps it was something like
- the crontab doesnt load an environment variable, so I need to use "absolute" values
- my user's permissions are not enough to load the default interface file

I tried different solutions without hope:
- first of all I assured that my user can reach and read the default interface file (/opt/sybase/interfaces)
- then checked the interfaces content

MYDATA
query tcp ether 127.0.0.1 2000
master tcp ether 127.0.0.1 2000
query tcp ether 210.92.92.1 2000
master tcp ether 210.92.92.1 2000
MYDATA_BACKUP
query tcp ether 127.0.0.1 4000
master tcp ether 127.0.0.1 4000
LOC
query tcp ether 127.0.0.1 2000
master tcp ether 127.0.0.1 2000
STANDBY
query tcp ether 210.92.92.2 2000
master tcp ether 210.92.92.2 2000

- I specified the -S option (tried bcp bla bla -S127.0.0.1 and as well -S210.92.92.1)
- created a new interface file in my home, specifying the server name like

MYDATA
query tcp ether 127.0.0.1 2000
master tcp ether 127.0.0.1 2000
query tcp ether 210.92.92.1 2000
master tcp ether 210.92.92.1 2000
query tcp ether MyServer 2000
master tcp ether MyServer 2000


I still can't realize if the problem resides on bcp, on the crontab, on the user... Thanks for any help.

p.s. if you have another option to dump data in a simple csv format, any solution is welcome.
 
The most common mistake when running scripts from cron is to forget to initialize your environment. Note; cron does not execute your profile
Add this line at the start of your sh/ksh/bash script
Code:
. ./opt/sybase/SYBASE.sh # Note dot space dot
 
Thanks for the support, it could be the cause since I didnt know that I had to initialize it.

Anyways there's no SYBASE.sh in the /opt/sybase folder, neither in the /opt/sybase/scripts folder. Could you please give me any hint? Or post the content of this script? I will give this solution another try.

Thanks again
 
What version of ASE are you using?
You are probably on an ancient version
I've checked on ASE 12.0, ASE 12.5 and 15.0.2 and the script is provided in the home directory.

For pre version 12, you probably need:
export SYBASE=/opt/sybase
export PATH=$SYBASE/bin:$PATH
export LD_LIBRARY_PATH=$SYBASE/lib
 
Actually the license file says it's 11.0.3.3 (docs directory have been removed) so you must be right.

I cat /etc/profile and it correctly sets up all the env variables (checked with printenv) as specified in the installation guide, so perhaps the script was removed.

I first tried adding `. ./etc/profile` in my bash script with no success, then tryed adding
export SYBASE=/opt/sybase
export PATH=$SYBASE/bin:$PATH (modified with the original paths I found in the original env)
export LD_LIBRARY_PATH=$SYBASE/lib (as above)

but nothing happens. So I tried to add instead
export HOSTNAME="127.0.0.1"

Echoed the output in a logfile and everytime the result was:
"DB-LIBRARY error: Server name not found in interface file."

There's something strange here...
 
I've reread your original post and now noticed that you use
-S127.0.0.1 or -S210.92.92.1

You should use the name i.e.
-SMYDATA
OR
-SSTANDBY
 
I already did it:

I tried specifying to bcp the Server option, adding -SMyServer

And, as said in the first post, I created a new interface file inside my home (I dont have write permissions in /opt/sybase), specifying the server name like

MYDATA
query tcp ether 127.0.0.1 2000
master tcp ether 127.0.0.1 2000
query tcp ether 210.92.92.1 2000
master tcp ether 210.92.92.1 2000
query tcp ether MyServer 2000
master tcp ether MyServer 2000

and then specifying to bcp the option -i/home/myuser/interface: I got the same result.
 
MYDATA
query tcp ether MyServer 2000
master tcp ether MyServer 2000

In the above MyServer is the sybase hostname
And the Sybase server name (sybase instance) to be used with the -S flag is MYDATA
 
Thanks, I solved it!

The -S option was exactly as you suggested me before:

-SMYDATA

This was the server name: the instance declared inside the /opt/sybase/interfaces file (in my example MYDATA), not the "networking" or the CN server name.

I hope it would be helpful for some other people.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top