×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

sybase bcp doesn't work with crontab

sybase bcp doesn't work with crontab

sybase bcp doesn't work with crontab

(OP)
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.

RE: sybase bcp doesn't work with crontab

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
 

RE: sybase bcp doesn't work with crontab

(OP)
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

RE: sybase bcp doesn't work with crontab

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

RE: sybase bcp doesn't work with crontab

(OP)
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...

RE: sybase bcp doesn't work with crontab

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
 

RE: sybase bcp doesn't work with crontab

(OP)
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.

RE: sybase bcp doesn't work with crontab

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

RE: sybase bcp doesn't work with crontab

(OP)
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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close