Solved

coldfusion running commands in windows

Posted on 2004-03-23
3
220 Views
Last Modified: 2013-12-20
How do I run batch commands from coldfusion?  Windows 2k server.

I'm trying to do FTP things that CFM can't seem to do with cfftp (like delte an entire directory w/out having to recusively loop).
0
Comment
Question by:happydog234
3 Comments
 
LVL 17

Accepted Solution

by:
Tacobell777 earned 500 total points
ID: 10663303
You could use <cfexecute> and use the windows ftp, i.e. command line ftp 192.168.200.1
0
 
LVL 4

Expert Comment

by:sandy12879
ID: 10664673
cfftp tag lets u perform tasks on remote server using file transfer protocol(ftp).

You can use cfftp to cache connections for batch file transfers when uploading or downloading files.

Just a pseudo code for u

html>
<head>
   <title>FTP Test</title>
</head>

<body>
<h1>FTP Test</h1>
<!--- Open ftp connection --->
<cfftp connection="Myftp"
   server="MyServer"
   username="MyUserName"
   password="MyPassword"
   action="Open"
   stoponerror="Yes">

<!--- Get the current directory name. --->
<cfftp connection=Myftp
   action="GetCurrentDir"
   stoponerror="Yes">

<!--- output directory name --->
<cfoutput>
   The current directory is:  #cfftp.returnvalue#<p>
</cfoutput>

<!--- Get a listing of the directory. --->
<cfftp connection=Myftp
   action="listdir"
   directory="#cfftp.returnvalue#"
   name="dirlist"
   stoponerror="Yes">
<!--- Close the connection.--->
<cfftp action="close" connection="Myftp">
<p>Did the connection close successfully?
   <cfoutput>#cfftp.succeeded#</cfoutput></p>

<!--- output dirlist results --->
<hr>
<p>FTP Directory Listing:</p>

<cftable query="dirlist" colheaders="yes" htmltable>
   <cfcol header="<B>Name</b>" TEXT="#name#">
   <cfcol header="<B>Path</b>" TEXT="#path#">
   <cfcol header="<B>URL</b>" TEXT="#url#">
   <cfcol header="<B>Length</b>" TEXT="#length#">
   <cfcol header="<B>LastModified</b>"
   TEXT="#DateFormat(lastmodified)#">
   <cfcol header="<B>IsDirectory</b>"
      TEXT="#isdirectory#">
</cftable>


After you establish a connection with cfftp, you can reuse the connection to perform additional FTP operations .

regards
Sandy
0
 
LVL 5

Expert Comment

by:Seth_Bienek
ID: 10684607
If you're wanting to run a batch FTP process (as from the command line), save your script in a batch file (need help with this? it sounds like you may already know the ropes in this arena), then call the batch file from CF using <cfexecute>:

<cfexecute name="c:\batchfiles\ftpscript.bat" timeout="600" outputfile="c:\batchfiles\log.txt">
</cfexecute>

You have to remember to add the closing tag, even though there's nothing in the middle.

Hope this helps,

Seth
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
I starting with php 12 137
Connect to MS-SQL server from Linux/PHP 8 89
Setting Up Local Lan Web Server 1 65
Code Manager | Snippits 2 37
In this short web based tutorial, I wanted to show users how they can still use the powers of FrontPage in conjunction with Expression Web 3.  Even though Microsoft eliminated the use of Web components, we can still use them with FrontPage and edit …
One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
The purpose of this video is to demonstrate how to make a WordPress Site faster and smaller in size by cleaning up the database. This will be demonstrated using a Windows 8 PC. Plugin WP Optimize will be used. Go to your WordPress login page. T…
The purpose of this video is to demonstrate how to manually back up a WordPress Database. This will be demonstrated using a Windows 8 PC. The Host used will be IPage.com Log into your Hosting account. IPage will be used for demonstration : Locat…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question