Executing OS commands from with ISQL for SQL Anywhere 
Author Message
 Executing OS commands from with ISQL for SQL Anywhere

Hi people,

I've written a master script that build other scripts in what should
be temorary files, and then runs these files.

I run the master script by issue the read command at the ISQL prompt.
What I'd like to do is add some operating system commands at the end
of the master script to delete the temporary files.  The doco and the
online help seems a bit bare in this respect, so I was wonder if
anyone knows if it's possible, and if so how?

Ciao
Fuzzy
:-)



Tue, 29 Feb 2000 03:00:00 GMT
 Executing OS commands from with ISQL for SQL Anywhere

: I've written a master script that build other scripts in what should
: be temorary files, and then runs these files.
:
: I run the master script by issue the read command at the ISQL prompt.
: What I'd like to do is add some operating system commands at the end
: of the master script to delete the temporary files.  The doco and the
: online help seems a bit bare in this respect, so I was wonder if
: anyone knows if it's possible, and if so how?

At the current time there is no way to invoke O/S commands from within
an SQL prompt.  You can use "!!" at the isql prompt interactively, but
it will cause errors when placed in a script or procedure.  I understand
that this capability will appear in a future release.

In the mean time, you could run your script as a shell script that invokes
isql to do the SQL work and then clean up your temp files at the end when
you are back in the shell environment.  This approach has worked well for
me when I've needed the same functionality.

                                Good luck,
                                Teresa Larson

     _________________________________________________________________
    /  Teresa A. Larson                 http://www2.ari.net/jmasino/ /
   /  Bell Atlantic                          Voice: (301) 282-0224  /
  /  13100 Columbia Pike, A-3-3              Fax:   (301) 282-9416 /

/________________________________________________________________/
                      #include <std_disclaimer>



Tue, 29 Feb 2000 03:00:00 GMT
 Executing OS commands from with ISQL for SQL Anywhere

Quote:

> Hi people,

> I've written a master script that build other scripts in what should
> be temorary files, and then runs these files.

> I run the master script by issue the read command at the ISQL prompt.
> What I'd like to do is add some operating system commands at the end
> of the master script to delete the temporary files.  The doco and the
> online help seems a bit bare in this respect, so I was wonder if
> anyone knows if it's possible, and if so how?

> Ciao
> Fuzzy
> :-)

Obviously those who've replied to your message haven't worked with SQL
Anywhere.

contents of runit.bat:
copy file1.sql + file2.sql input.sql
isql -c "uid=dba;pwd=sql;.." read input.sql
del input.sql

when this bat file runs it invokes isql in the background so the delete
of input.sql happens before isql attempts to read from the file and it
gets an error. The question is: "How can I delete input.sql AFTER isql
completes?"

Russ



Wed, 01 Mar 2000 03:00:00 GMT
 Executing OS commands from with ISQL for SQL Anywhere

Quote:

> Hi people,

> I've written a master script that build other scripts in what should
> be temorary files, and then runs these files.

> I run the master script by issue the read command at the ISQL prompt.
> What I'd like to do is add some operating system commands at the end
> of the master script to delete the temporary files.  The doco and the
> online help seems a bit bare in this respect, so I was wonder if
> anyone knows if it's possible, and if so how?

> Ciao
> Fuzzy
> :-)

Look in the SQLAnywhere help file for extended stored procedures which
allows a dll to be invoked.
Sybase has provided 3 dlls including a command shell.  

Here is a snip from the help:
================================================================================================
Syntax

[ variable = CALL ] xp_cmdshell ( string )

Purpose
To carry out an operating system command from a procedure.
Usage
Anywhere.
Authorization
None.
Description
xp_cmdshell is a system stored procedure that executes a system command
and then returns control to the calling environment.
Example
The following statement lists the files in the current directory in the
file C:\TEMP.TXT

xp_cmdshell('dir > c:\\temp.txt')



Fri, 03 Mar 2000 03:00:00 GMT
 Executing OS commands from with ISQL for SQL Anywhere



Quote:

>> Hi people,

>> I've written a master script that build other scripts in what should
>> be temorary files, and then runs these files.

>> I run the master script by issue the read command at the ISQL prompt.
>> What I'd like to do is add some operating system commands at the end
>> of the master script to delete the temporary files.  The doco and the
>> online help seems a bit bare in this respect, so I was wonder if
>> anyone knows if it's possible, and if so how?

>> Ciao
>> Fuzzy
>> :-)

>Look in the SQLAnywhere help file for extended stored procedures which
>allows a dll to be invoked.
>Sybase has provided 3 dlls including a command shell.  

>Here is a snip from the help:
>================================================================================================
>Syntax

>[ variable = CALL ] xp_cmdshell ( string )

>Purpose
>To carry out an operating system command from a procedure.
>Usage
>Anywhere.
>Authorization
>None.
>Description
>xp_cmdshell is a system stored procedure that executes a system command
>and then returns control to the calling environment.
>Example
>The following statement lists the files in the current directory in the
>file C:\TEMP.TXT

>xp_cmdshell('dir > c:\\temp.txt')

Carl,

Thanks for this.  Interestingly, if you use this procedure on a client
machine, the OS command is executed on the server!  Back to the
drawing board.

Thanks.
Fuzzy
:-)



Sat, 04 Mar 2000 03:00:00 GMT
 
 [ 6 post ] 

 Relevant Pages 

1. Executing OS command from PL/SQL

2. OS Commands in ISQL

3. Executing query with -Q of isql command

4. SYBASE, execute UNIX command within isql, with arguments ?

5. SYBASE, execute UNIX command within isql

6. permission denied ,while executing OS command on server (linux)

7. Executing and OS command from a database trigger or stored procedure

8. Executing os-commands from with an procedure/function

9. Can I execute OS command in stored procedure ?

10. Execute OS Command from Procedure/Trigger

11. SQL AnyWhere 5.0 isql ?

12. Connect from isql in SQL Anywhere 5.0 to Sybase System 10 on HP-UX


 
Powered by phpBB® Forum Software