Running a C-Shell Script

Running a C-Shell Script

Post by Buck Turgidso » Mon, 27 Jan 2003 00:26:01



I am trying to run this script that I found, and am getting an error.  I
normally use bash.  I have tried 2 different ways to run it, and I get
errors on both.  I would appreciate any advice:

--Using bash


: Command not found.

--Using C Shell


/home/oracle> host.csh
'nknown option: `-
Usage: csh [ -bcdefilmnqstvVxX ] [ argument ... ].

---------------------begin file

#!/bin/csh -f

sqlplus buck/password <<"EOF" | grep '^#' | sed 's/^.//' > tmp.csh

set serveroutput on

declare
        status  number;
        command varchar2(255);
begin
        status := dbms_pipe.receive_message( 'HOST_PIPE' );
        if ( status <> 0 ) then
                dbms_output.put_line( '#exit' );
        else
                dbms_pipe.unpack_message( command );
                dbms_output.put_line( '##!/bin/csh -f' );
                dbms_output.put_line( '#' || command );
                dbms_output.put_line( '#exec host.csh' );
        end if;
end;
/
spool off
"EOF"

chmod +x tmp.csh
exec tmp.csh

---------------------end file

 
 
 

Running a C-Shell Script

Post by Pascal Bourguigno » Mon, 27 Jan 2003 01:48:41



> I am trying to run this script that I found, and am getting an error.  I
> normally use bash.  I have tried 2 different ways to run it, and I get
> errors on both.  I would appreciate any advice:

> --Using bash


> : Command not found.

With tcsh,  it seems to  work (replacing sqlplus buck/password  by cat
since I don't have a running oracle).

Since it objects on ':', I'd say that your csh can't parse <<"EOF"|grep ...

Either use bash, or try to do it with a temporary file:
#!/bin/csh -f
sqlplus buck/password >tmp1 <<"EOF"
...
EOF
grep '^#' tmp1| sed 's/^.//' > tmp.csh

Since you don't use anything specific to csh, you can just replace the
first line by: #!/bin/sh

Quote:> --Using C Shell

          ^
This is the error.


> /home/oracle> host.csh
> 'nknown option: `-
> Usage: csh [ -bcdefilmnqstvVxX ] [ argument ... ].

> ---------------------begin file

> #!/bin/csh -f

> sqlplus buck/password <<"EOF" | grep '^#' | sed 's/^.//' > tmp.csh

> set serveroutput on

> declare
>         status  number;
>         command varchar2(255);
> begin
>         status := dbms_pipe.receive_message( 'HOST_PIPE' );
>         if ( status <> 0 ) then
>                 dbms_output.put_line( '#exit' );
>         else
>                 dbms_pipe.unpack_message( command );
>                 dbms_output.put_line( '##!/bin/csh -f' );
>                 dbms_output.put_line( '#' || command );
>                 dbms_output.put_line( '#exec host.csh' );
>         end if;
> end;
> /
> spool off
> "EOF"

> chmod +x tmp.csh
> exec tmp.csh

> ---------------------end file

--
__Pascal_Bourguignon__                   http://www.informatimago.com/
----------------------------------------------------------------------
There is a fault in reality. Do not adjust your minds. -- Salman Rushdie

 
 
 

Running a C-Shell Script

Post by Neil Cher » Mon, 27 Jan 2003 05:20:54



>I am trying to run this script that I found, and am getting an error.  I
>normally use bash.  I have tried 2 different ways to run it, and I get
>errors on both.  I would appreciate any advice:

>--Using bash


>: Command not found.

>--Using C Shell


>/home/oracle> host.csh
>'nknown option: `-
>Usage: csh [ -bcdefilmnqstvVxX ] [ argument ... ].

>---------------------begin file

>#!/bin/csh -f

I'm willing to bet that the path to csh isn't /bin/csh, use the
following command to find it's path:

type csh

On all my systems csh is in /bin, oh check to see if it's a link (
ls -l <PATH_To_csh>) and see if the link is good. I hope that helps.

--

http://mywebpages.comcast.net/ncherry/                  (Text only)
http://linuxha.sourceforge.net/                         (SourceForge)
http://hcs.sourceforge.net/                             (HCS II)

 
 
 

Running a C-Shell Script

Post by Bill Marcu » Mon, 27 Jan 2003 07:32:23


On Sat, 25 Jan 2003 15:26:01 GMT, Buck Turgidson


> 'nknown option: `-

This error seems to indicate that the script contains control characters.
You probably copied it from a Windoze machine without using "dos2unix"
or a similar filter.
 
 
 

Running a C-Shell Script

Post by Buck Turgidso » Mon, 27 Jan 2003 08:58:57


All excellent responses.  Thanks.  This is what the problem was.  I use
samba and Visual Slick Edit.  I saved it as type UNIX rather than DOS.


> On Sat, 25 Jan 2003 15:26:01 GMT, Buck Turgidson

> > 'nknown option: `-
> This error seems to indicate that the script contains control
characters.
> You probably copied it from a Windoze machine without using "dos2unix"
> or a similar filter.

 
 
 

Running a C-Shell Script

Post by Duane Clar » Mon, 27 Jan 2003 12:35:00



> All excellent responses.  Thanks.  This is what the problem was.  I use
> samba and Visual Slick Edit.  I saved it as type UNIX rather than DOS.

Or instead of going to all the trouble of samba and Visual Slick Edit,
you might want to try NEdit, which will also read/write/convert unix and
dos formats, and is a superb editor too.
http://www.nedit.org/

--

 
 
 

1. c-shell script won't run from korn-shell / SETUID

Greetings,

I have a C program called "tryme" which does a system call
to run a korn-shell script called "trythis.ksh".  This script
calls a C-shell script called "goforit".

My original program "tryme" runs SETUID as user "joe" so
the permissions on "tryme" look like this:

     -rwsr-x---  1 joe   sd   3083 Nov  9  19:06 tryme

The two scripts are executable by everybody.  When I run "tryme"
it calls "trythis.ksh" without problems, but when "trythis.ksh"
then calls the C-shell script "goforit", an error is produced
saying:

    "csh: The file access permissions do not allow the specified
     action."

When I turn off the SETUID permission from tryme and the rerun
it, everything works just fine.  Does anybody know why turning
on SETUID for tryme has an adverse affect on the c-shell script?

-Steve

2. Wireless PCI Card Linksys WMP11

3. Shell Script Help (C-Shell Script)

4. How to mount ZIP (SCSI)

5. Clear screen while running C-shell script based on echo's

6. Need help of infomation of Solaris2.5 ddi programing

7. How to run rn in a c-shell script

8. Boot Disk Help

9. How to refresh screen while running c-shell script?

10. a question about executing a shell script (c-shell)

11. Help with c-shell script

12. Date arithmetic in C-Shell scripts?

13. C-Shell/Perl Scripts for Scheduling FTP Proxy Transfers