Server-side scripts with ASP

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bill Sneddon

    Server-side scripts with ASP

    Sorry if this is an easy question.

    Does Javascript work "out of the box with IIS" as an
    Active server page? ie. does it have the ability to open files
    ect.?

    I tried this command and it does not seem to work.

    var fileSys;
    var txtFile;
    fileSys = new ActiveXObject(" Scripting.FileS ystemObject");
    txtFile = fileSys.OpenTex tFile("./junk.txt",1,fal se);

    I can't find examples on the web. What would I search for to find out
    about objects the Scripting.FileS ystemObject?

    Background
    I work at a large company with a corperate IT group.
    I need to write some server side scripts. The servers they
    have are Windows 2000 with IIS installed. If additional
    software needs to be installed I will be forced to use VBscript.

    Bill

  • Laurent Bugnion, GalaSoft

    #2
    Re: Server-side scripts with ASP

    Hi,

    Bill Sneddon wrote:[color=blue]
    > Sorry if this is an easy question.
    >
    > Does Javascript work "out of the box with IIS" as an
    > Active server page? ie. does it have the ability to open files
    > ect.?[/color]

    Yes. You don't need special libraries, JScript is installed. However,
    you might need to specify on your pages that JScript should be used
    instead of VBScript. To do this, place this line on top of the ASP page:

    <%@ Language=JavaSc ript %>

    This should be the first line of the page.

    [color=blue]
    > I tried this command and it does not seem to work.
    >
    > var fileSys;
    > var txtFile;
    > fileSys = new ActiveXObject(" Scripting.FileS ystemObject");
    > txtFile = fileSys.OpenTex tFile("./junk.txt",1,fal se);[/color]

    I don't find a OpenTextFile method for the FileSysteObject .

    Do you mean:
    txtFile = fileSys.CreateT extFile( "c:\\testfile.t xt", true );

    Note the windows notation (backslash as path separator instead of slash)!!

    More documentation about the FileSystemObjec t: See MSDN
    <URL:
    http://msdn.microsoft. com/library/default.asp?url =/library/en-us/script56/html/sgfsosample.asp >


    [color=blue]
    > I can't find examples on the web. What would I search for to find out
    > about objects the Scripting.FileS ystemObject?
    >
    > Background
    > I work at a large company with a corperate IT group.
    > I need to write some server side scripts. The servers they
    > have are Windows 2000 with IIS installed. If additional
    > software needs to be installed I will be forced to use VBscript.
    >
    > Bill[/color]

    That would be a shame ;-)

    HTH,

    Laurent
    --
    Laurent Bugnion, GalaSoft
    Webdesign, Java, JavaScript: http://www.galasoft-LB.ch
    Private/Malaysia: http://mypage.bluewin.ch/lbugnion
    Support children in Calcutta: http://www.calcutta-espoir.ch

    Comment

    • Jim Dabell

      #3
      Re: Server-side scripts with ASP

      Bill Sneddon wrote:
      [color=blue]
      > Does Javascript work "out of the box with IIS" as an
      > Active server page? ie. does it have the ability to open files
      > ect.?[/color]

      JScript does, yes.

      [color=blue]
      > I tried this command and it does not seem to work.[/color]

      "Does not seem to work" is about as vague as you can get. Blank page?
      Browser hang? Error message? Source shown? Every molecule in your body
      exploding at the speed of light?

      [color=blue]
      > var fileSys;[/color]

      Only code within <% %> blocks is processed on the server.

      [color=blue]
      > var txtFile;
      > fileSys = new ActiveXObject(" Scripting.FileS ystemObject");
      > txtFile = fileSys.OpenTex tFile("./junk.txt",1,fal se);
      >
      > I can't find examples on the web. What would I search for to find out
      > about objects the Scripting.FileS ystemObject?[/color]
      [snip]

      It's a normal COM object. Just look at the (numerous) VBScript examples and
      adapt it to JScript syntax.


      -
      Jim Dabell

      Comment

      • Steve van Dongen

        #4
        Re: Server-side scripts with ASP

        On Wed, 03 Sep 2003 22:58:16 +0200, "Laurent Bugnion, GalaSoft"
        <galasoft-LB@bluewin_NO_S PAM.ch> wrote:
        [color=blue]
        >Hi,
        >
        >Bill Sneddon wrote:[/color]
        [color=blue][color=green]
        >> I tried this command and it does not seem to work.
        >>
        >> var fileSys;
        >> var txtFile;
        >> fileSys = new ActiveXObject(" Scripting.FileS ystemObject");
        >> txtFile = fileSys.OpenTex tFile("./junk.txt",1,fal se);[/color]
        >
        >I don't find a OpenTextFile method for the FileSysteObject .[/color]

        It's there.

        FSO works with real files, not URLs, so use Server.MapPath to get the
        path to the file on your filesystem.

        txtFile = fileSys.OpenTex tFile(Server.Ma pPath(".") + "\\junk.txt ",
        1, false);
        [color=blue]
        >Note the windows notation (backslash as path separator instead of slash)!!
        >
        >More documentation about the FileSystemObjec t: See MSDN
        ><URL:
        >http://msdn.microsoft. com/library/default.asp?url =/library/en-us/script56/html/sgfsosample.asp >[/color]

        Regards,
        Steve

        Comment

        • Laurent Bugnion, GalaSoft

          #5
          Re: Server-side scripts with ASP

          Hi,

          Steve van Dongen wrote:
          [color=blue]
          > On Wed, 03 Sep 2003 22:58:16 +0200, "Laurent Bugnion, GalaSoft"
          > <galasoft-LB@bluewin_NO_S PAM.ch> wrote:[/color]
          [color=blue][color=green]
          >>I don't find a OpenTextFile method for the FileSysteObject .[/color]
          >
          >
          > It's there.[/color]

          I believe you alright ;-) I checked it up in MSDN quite late last night,
          and was aware that my unability to find it in the MSDN jungle didn't
          mean it was not there ;-)

          Laurent
          --
          Laurent Bugnion, GalaSoft
          Webdesign, Java, JavaScript: http://www.galasoft-LB.ch
          Private/Malaysia: http://mypage.bluewin.ch/lbugnion
          Support children in Calcutta: http://www.calcutta-espoir.ch

          Comment

          • Bill Sneddon

            #6
            Re: Server-side scripts with ASP

            Thanks All.

            It is working now. I think my problem was related to the path.
            As Steve suggested.

            Thanks again ... glad I don't have to use VB script!!

            Comment

            Working...