isql command problem

  • Hi guys,

    I am facing some problem using the isql statement.

    The output of my query is position specific ...and i need some fields to start at a particular position..so any deviation

    on the field position is not acceptable.

    I am using isql to get the output of a stored procedure in a text file, however in my text file the fields start from

    position 2, instead of position 1. It means that isql inserts leading spaces before the record.

    please let me know if anyone knows a work-arround for this.

    Thanks

    Raxit

  • You can try a switch like -s"" to reduce the column separator to nothing, which will remove the leading space, but the consequence of this is that no separator will appear between output columns.


    Cheers,
    - Mark

  • I wrote a script to delete leading space.

    Save it to delleadingspace.wsf

    Find syntax by delleadingspace.wsf /?

    <job id="delleadingspace">

     <runtime>

      <unnamed

        name="filename"

        helpstring="The file to process"

        many="false"

        required=2

      />

      <usage>

       Delete line leading space from a text file.

       Example: delete leading space from SourceFile and put result into DestinationFile.

       delleadingspace.wsf SourceFile DestinationFile.

       SourceFile text file must be exist.

      </usage>

     </runtime>

     <script language="VBScript">

     Function RegExpTest(patrn, oristr, repstr)

       Dim regEx

       Set regEx = New RegExp

       regEx.Pattern = patrn

       regEx.IgnoreCase = True

       regEx.Global = True

       RegExpTest = regEx.Replace(oristr,repstr)

     End Function

     dim objArgs, fso, sfile, dfile

     Set objArgs = WScript.Arguments

     sfile = objArgs(0)

     dfile = objArgs(1) 

     'check SourceFile exists

     Set fso = CreateObject("Scripting.FileSystemObject")

     If not (fso.FileExists(sfile)) Then

       WScript.Arguments.ShowUsage

       WScript.Quit(1) 'err out

     end if

     'open sourcefile for reading and destinationfile for writing

     dim rsfile, wdfile, line, patrn

     set rsfile = fso.opentextfile(sfile,1)

     set wdfile = fso.opentextfile(dfile,2,true)

     patrn = "^\x20+"

     while rsfile.atendofstream <> true

      line = rsfile.readline

      wdfile.writeline RegExpTest(patrn,line, "") 'delete leading space(s)

     wend

     rsfile.close

     wdfile.close

     WScript.Quit(0)

     </script>

    </job>

  • Why not use "sed" for Windows?

    sed "s/^[ \t]*//" filename

    Removes all leading whitespaces.

    Regards, Peter.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply