Solved

coldfusion running commands in windows

Posted on 2004-03-23
3
233 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

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…
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
The purpose of this video is to demonstrate how to automatically show related posts at the bottom of a blog post in WordPress. This will be demonstrated using a Windows 8 PC. Plugin “Yet Another Related Posts Plugin” will be used. Go to your…
The purpose of this video is to demonstrate how to update a WordPress Site’s version. WordPress releases new versions of its software frequently and it is important to update frequently in order to keep your site secure, and to get new WordPress…

630 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