Solved

coldfusion running commands in windows

Posted on 2004-03-23
3
228 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

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

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

Suggested Solutions

Introduction In this tutorial, I'll explain how to create an animated progress meter in a wireframe prototype developed using Axure RP 7.0 - a leading prototyping tool for designing web sites and software. (For more information about Axure and gett…
Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.
The purpose of this video is to demonstrate how to add AdSense Ads to a WordPress Website, and how to set up WordPress to automatically place Ads in Sidebars. This will be demonstrated using a Windows 8 PC. Log into your AdSense account. : Cli…
The purpose of this video is to demonstrate how to set up basic WordPress SEO. This will be demonstrated using a Windows 8 PC. The plugin used will be WordPress SEO by Yoast. Go to your WordPress login page. This will look like the following: myw…

710 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