Re: .bat from asp.net w/System.Diagnostics.Process?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Alvin Bruney [MVP] (vapor)
Date: 04/12/04


Date: Sun, 11 Apr 2004 23:21:13 -0500

Great, so here is where you start. After each line in your script, echo it
to the screen. Then run the app. Just follow the screen output to find which
line is failing.

-- 
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/27cok
<danl@drawnet_no_spam.com> wrote in message 
news:E78DD3A6-E09C-4498-ABF2-3BE502BC75EB@microsoft.com...
> The results of the script from the command prompt when run from an .aspx 
> are
> ====================
>     > Microsoft Windows XP [Version 5.1.2600] (C) Copyright 1985-2001 
> Microsoft
>     > Corp. C:\WINDOWS\system32>ftp -s:c:\ftp_scripts\ftp.txt >>> 
> c:\ftp_scripts\dbftplog.txt C:\WINDOWS\system32>
> ====================
> The ftp call syntax that I am using allows you to have a text file with 
> all of your ftp connection info in it. The contents of the 
> c:\ftp_scripts\ftp.txt file is
> ===================
> open 11.22.33.44
> uname
> pword
> cd mydir
> put "C:\SQLData\MSSQL\BACKUP\test.txt"
> quit
> ===================
>
> I'd really like to figure out why my code won't run from a web page, but I 
> really just need to be able to ftp from an .aspx page. If you know of a 
> better way, I'm open to anything that works.
>
> Thanks for your help.
> -Dan
>
>
>     ----- Alvin Bruney [MVP] wrote: -----
>
>     what is the results of the script from the command prompt when you run 
> using
>     a webpage?
>     i'm not familiar with the syntax of the ftp command you are using. 
> from the
>     docs, ftp takes a verb followed by command line options. Post your 
> script
>     code if you still have problems.
>
>     -- 
>     Regards,
>     Alvin Bruney [ASP.NET MVP]
>     Got tidbits? Get it here...
>     http://tinyurl.com/27cok
>     <danl@drawnet_no_spam.com> wrote in message
>     news:58DDAD5C-C363-473A-AEDE-EEF9B98CD855@microsoft.com...
>     > Thanks for your help Alvin, but I still can't get the sript to run. 
> I
>     > tried to simplify the code by executing the command that was in the 
> bat
>     > file directly from this script, still no luck.
>     >> The cmd simply takes a file and ftp's it to another server. the 
> output is
>     > recorded in a log file. If I execute the cmd from the cmd line, it 
> works
>     > fine (the file is moved, and there is an entry in the log file).
>     >> When I execute it with the following script from an .aspx, no file 
> moved
>     > and no log entry.
>     >> I'm stumped!! Any other idea's why this might not be working?
>     >> =======================================
>     > System.Diagnostics.Process p = new Process();
>     > p.StartInfo.RedirectStandardOutput=true;
>     > p.StartInfo.RedirectStandardInput=true;
>     > p.StartInfo.FileName = @"cmd";
>     > p.StartInfo.UseShellExecute=false;
>     > p.Start();
>     > StreamWriter sIn = p.StandardInput;
>     > sIn.AutoFlush  = true;
>     > StreamReader sOut = p.StandardOutput;
>     >> sIn.Write(@"ftp -s:c:\ftp_scripts\ftp.txt >> 
> c:\ftp_scripts\ftp_log.txt" +
>     > System.Environment.NewLine);
>     > sIn.Close();
>     >> string results = sOut.ReadToEnd().Trim();
>     > p.Close();
>     >> Response.Write(results);
>     > ===========================================
>     >> OUTPUT
>     > ===========================================
>     > Microsoft Windows XP [Version 5.1.2600] (C) Copyright 1985-2001 
> Microsoft
>     > Corp. C:\WINDOWS\system32>ftp -s:c:\ftp_scripts\ftp.txt >>> 
> c:\ftp_scripts\dbftplog.txt C:\WINDOWS\system32>> 
> ===========================================
>
>
> 


Relevant Pages

  • Re: Run scripts from WITHIN the FTP environment
    ... Go look up how to do scripting with a batch file in FTP. ... If you think the FTP command can be brainless and NOT have a file on the ... There is no way to "push" a script to the computer without having the user ... to execute a script in the directory they are in. ...
    (microsoft.public.inetserver.iis.ftp)
  • Re: Scripted FTP transfer
    ... Rather then specify the username and password in your script, ... going to run the ftp script, ... If you are running this from root, the .netrc will be created in / ... I'm trying to write a FTP command file on the fly to ...
    (comp.unix.sco.misc)
  • Re: Scripted FTP transfer
    ... I'm attempting to script an FTP transfer on my UnixWare 7.1.4 server. ... I'm trying to write a FTP command file on the fly to redirect ...
    (comp.unix.sco.misc)
  • Re: Run scripts from WITHIN the FTP environment
    ... Your script I assume uses the Windows command line based FTP program? ... to execute a script in the directory they are in. ...
    (microsoft.public.inetserver.iis.ftp)
  • Re: Problems trying to configure Linux laptop to print to Windows XP shared printer
    ... map to guest = Never ... check password script = ... enumports command = ... ldap delete dn = No ...
    (comp.os.linux.setup)