Just following on from my previous question, does anyone know how to use VB 
with nant to get input from the user using the <script> tag? An example of 
printing output to the screen using VB is given at 
http://nant.sourceforge.net/release/latest/help/tasks/script.html as follows:

 

<script language="VB">
          <code>
            <![CDATA[
              Public Shared Sub ScriptMain(project As Project)
                  project.Log(Level.Info, "Hello World from a script task using 
Visual Basic.NET")
              End Sub
            ]]>
          </code>
      </script>

That's great, but I do not know how to get input from the user? I have tried to 
run VB scripts using NAnt but it does not seem to work correctly so I am 
obviously doing something wrong. I don't properly understand how to use the 
project parameter required for ScriptMain, and the link for the project 
paramneter 
(http://nant.sourceforge.net/release/latest/sdk/NAnt.Core.Project.html) is not 
working. Ideally, I want to be able to run a VB script such as the one that 
follows within NAnt to gain input from the user:

 
Module Example
    Sub Main()
        Dim username As String
        Dim password As String                Console.WriteLine("Username ?")
        name = Console.ReadLine()
        
        Console.WriteLine("Password ?")
        age = Console.ReadLine()        'rest of code....
        
    End Sub
End Module
Simply adding this code within the CDATA block does not work and I do not 
understand how to convert the VB script using the appropriate syntax. Can 
anyone help me with this? Thanks!
 
> Date: Sun, 18 Apr 2010 21:55:30 -0700
> Subject: Re: [NAnt-users] Running a bat file
> From: rmbo...@gmail.com
> To: yo...@live.com
> CC: nant-users@lists.sourceforge.net
> 
> Hi,
> 
> 2010/4/18 Simon H <yo...@live.com>:
> > You are probably correct that the batch file is waiting for input from NAnt
> > as it does not seem that control has been properly passed to cmd.exe to
> > accept user input. I will explain what I need to do further to clarify why
> > it is desirable to use a bat file like this with NAnt.
> >
> > I am designing a automated compilation script for an Oracle Forms and
> > Reports development environment containing numerous databases with
> > associated projects. As the username and password for connecting to the
> > databases differs, and because of organisational measures in place that
> > require that developers are not privy to the username and password for
> > various databases (only DBA's have these rights), the ideal solution is to
> > prompt the user (whether it be developer or DBA) for the username, password
> > and database relevant to the files they wish to have automatically
> > compiled. As a bat file that achieves most of this functionality has already
> > been created, I was hoping to use that since I have not learnt any of
> > the scripting languages supported by NAnt and I am not aware of any other
> > way to achieve what I need. Do you have any suggestions for how I
> > can achieve what I need?
> 
> Well, the only thing I can think of is setting up the nant build file
> to pass the username, password, and database name to the batch scripts
> through the <exec> <args> command. I understand the security issues
> at hand for this but you could have the user set the login
> credentials in the command line, like so:
> 
> "nant -D:username=user -D:password:pw -D:database=exampleDB"
> 
> Of course, this means that the batch file needs to be updated to
> accept commandline arguments.
> 
> There may be a better approach to this but this is the only one coming
> to mind right now.
> 
> Thanks,
> Ryan
> 
> >
> >> Date: Sun, 18 Apr 2010 21:23:31 -0700
> >> Subject: Re: [NAnt-users] Running a bat file
> >> From: rmbo...@gmail.com
> >> To: yo...@live.com
> >> CC: nant-users@lists.sourceforge.net
> >>
> >> Hi,
> >>
> >> At first glance, the reason why it freezes is because it looks like
> >> the batch file is waiting for user input that NAnt isn't providing.
> >>
> >> I'm sorry, I have to ask. Why are you running a batch file from a
> >> NAnt build file? Seems like overkill to me, unless you have a
> >> specific need for it.
> >>
> >> Thanks,
> >> Ryan
> >>
> >> 2010/4/18 Simon H <yo...@live.com>:
> >> > Hi guys,
> >> >
> >> > I'm trying to run a bat file that displays a menu and accepts user input
> >> > from the commandline as input. To clarify, here is an excerpt of the bat
> >> > file:
> >> >
> >> > :topoffile
> >> > @echo off
> >> > @echo =================================================
> >> > @echo This is an Oracle Forms Compilation facility
> >> > @echo =================================================
> >> > @echo.
> >> >
> >> > :accountagain
> >> > @echo off
> >> > @echo Please enter Schema owner account and
> >> > set /p schemaowner=press return key, or QUIT to end:
> >> > if /i [%schemaowner%]==[QUIT] endlocal&goto end
> >> > @echo.
> >> > @echo =================================================
> >> > @echo Schema owner account entered was: '%schemaowner%'
> >> > @echo =================================================
> >> > if [%schemaowner%]==[] goto WrongAccount
> >> > @echo.
> >> >
> >> > In my nant build file I have the following target code:
> >> >
> >> > <target name="menu" description="display build menu">
> >> > <!-- password.bat is in the project basedir -->
> >> > <exec program="password.bat">
> >> > </target>
> >> >
> >> > However, when I run the build file I get the following output:
> >> >
> >> > menu:
> >> >
> >> >      [exec] ♀♀=====================================
> >> >      [exec] This is an Oracle Forms Compilation Facility
> >> >      [exec] =======================================
> >> >      [exec]
> >> >      [exec] Please enter Schema owner account and
> >> >
> >> > The execution of the bat file stops/freezes and cmd.exe will not accept
> >> > any
> >> > input and I have to Ctrl+C to return to the command prompt. How do I get
> >> > nant to correctly execute the bat file? Thanks in advance!
> >> >
> >> > ________________________________
> >> > Meet local singles online. Browse profiles for FREE!
> >> >
> >> > ------------------------------------------------------------------------------
> >> > Download Intel&#174; Parallel Studio Eval
> >> > Try the new software tools for yourself. Speed compiling, find bugs
> >> > proactively, and fine-tune applications for parallel performance.
> >> > See why Intel Parallel Studio got high marks during beta.
> >> > http://p.sf.net/sfu/intel-sw-dev
> >> > _______________________________________________
> >> > NAnt-users mailing list
> >> > NAnt-users@lists.sourceforge.net
> >> > https://lists.sourceforge.net/lists/listinfo/nant-users
> >> >
> >> >
> >
> > ________________________________
> > Find it at CarPoint.com.au New, Used, Demo, Dealer or Private?
                                          
_________________________________________________________________
If It Exists, You'll Find it on SEEK. Australia's #1 job site
http://clk.atdmt.com/NMN/go/157639755/direct/01/
------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
NAnt-users mailing list
NAnt-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nant-users

Reply via email to