home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!kddlab!jcpltyo!ohayon
- From: ohayon@jcpltyo.JCPL.CO.JP (Tsiel Ohayon)
- Newsgroups: comp.databases.sybase
- Subject: Re: Hiding a password while dumping
- Message-ID: <94@jcpltyo.JCPL.CO.JP>
- Date: 9 Nov 92 23:33:17 GMT
- References: <1688@anagld.analytics.com> <93@jcpltyo.JCPL.CO.JP>
- Organization: James Capel Pacific Limited, Tokyo Japan
- Lines: 88
-
-
- After recieving a few E-mails, I'm posting the following C program
- which dumps a Sybase database. It is not optimal but works
- great.
-
- ------------->8------------------ CUT HERE ----------------------------8<--
-
- #include <stdio.h>
- #include <time.h>
-
- #include <sybfront.h>
- #include <sybdb.h>
- #include <syberror.h>
-
- /* This is the main flaw, since you need to write your login or password in
- the C program. But you have the advantage of just needing to leave a
- compiled version on your server
- */
-
- #define DATABASE "database_name"
- #define LOGIN_NAME "sa"
- #define PASSWORD "sa_password"
- #define APP_NAME "dump"
-
- void
- main(argc,argv)
- unsigned int argc;
- char **argv;
- {
- long t;
- struct tm *period;
- DBPROCESS *dbproc;
- LOGINREC *login;
-
- time(&t);
- period = (struct tm *)localtime(&t);
-
- /* INITIALIZE SYBASE */
- if (dbinit() == NULL) {
- printf("Error opening the DB\n");
- exit(ERREXIT);
- }
-
- if ((login = dblogin()) == NULL) {
- (void)printf("dblogin() error, exiting \n");
- exit(1);
- }
- DBSETLUSER(login,LOGIN_NAME);
- DBSETLPWD(login, PASSWORD);
- DBSETLAPP(login, APP_NAME);
-
- if ((dbproc = dbopen(login,NULL)) == NULL) {
- (void)printf("dbopen() error, exiting \n");
- exit(1);
- }
-
- /* show time at which dump started */
- (void)printf("DUMPING DATABASE at %.2d:%.2d ...\n",period->tm_hour,
- period->tm_min);
-
- dbfcmd(dbproc,"dump database %s to tapedump",DATABASE);
- dbsqlexec(dbproc);
- while (dbresults(dbproc) != NO_MORE_RESULTS);
-
- if ((period->tm_wday == 1) || (period->tm_wday == 4)){
- (void)printf("DUMPING TRANSACTION ...\n");
- dbfcmd(dbproc,"dump transaction %s to tapedump\n",DATABASE);
- dbcmd(dbproc,"with truncate_only");
- dbsqlexec(dbproc);
- while (dbresults(dbproc) != NO_MORE_RESULTS);
- }
-
- /* show time at which dump finished */
- time(&t);
- period = (struct tm *)localtime(&t);
- (void)printf("FINISHED DUMPING DATABASE at %.2d:%.2d ...\n",
- period->tm_hour,period->tm_min);
- dbexit();
- exit(0);
- }
- ------------->8------------------ CUT HERE ----------------------------8<--
-
- Cheers,
- --
- ----8<--------------------------------------------------------------->8------
- Tsiel:ohayon@jcpl.co.jp | If you do not recieve this E-mail, please let me
- Employer may not have same | know as soon as possible, if possible.
- opinions, if any ! | Two percent of zero is almost nothing.
-