FTP Job Problem
I'm struggling with an issue with an SFTP job that fails no matter what with the following;
In the Audit Log tab, it reports that "There is a problem with spool file for job"
In the Output tab it reports "FTP JOB Failed : Attempted to read or write protected memory. This is often an indication that other memory is corrupt"
I've tried everything I can think of short of rebooting the master server. Uninstalling/restinalling/restarting agents, deleteing and recreating the job, restarting the master service. Nothing seems to correct the problem. I have other SFTP jobs on other machines working just fine.
Has anyone seen this issue before or have some info on how to resolve it? Thanks!
I would normally start by running the process outside ot TIDAL using WinSCP. If it works in that product, then I would point to TIDAL. In Tidal there are many things to look at.
1) User ID corrrect?
2) Password correct for logon user to FTP site?
3) Site your going to, is it only FTP and not SFTP?
4) The FTP Host, are you specifing a port? blah.blah.com:22
5) Do you have to use an IP address instead of the DNS? I had that issue recently.
6) Local User, I never have one in that option, I always leave blank.
7) File system full. I ran into the /logs filling up the hard drive and nothing would FTP.
8) Try it from another box. It could be hardware.
Similar Messages
-
Hello,
I have read lots of threads for FTP receiver problems wiht overwriting files....
But I am not sure which is the correct solution.
We have:
- Cluster (6nodes), PI711 (SP03)
- a time stamp shoudl be in the file name
- there is dynamice filename, because first char of the filename must be set from mapping
- each mesasge must be put in a single file (not APPEND mode)
After few test it seems that files are overwriten.
I tried ADD MESSAGEID, which seems to work correctly, but with dynamic filenametimestampmsgid the filename is to long for the next application.
I saw in a note, that the cluster can be the problem....
Any idea how I can solve my problem?
Does "use temporaly filename" help?
How is it used correctly????
best reagrds
WernerHi Werner,
In Processing Parameters tab, keep the file construction mode as "Add timestamp" and in the Putfile use" Use Temporary file". This should help you...
Refer the below link regarding Configuring the Receiver FTP Adapter
http://help.sap.com/saphelp_nwpi711/helpdata/en/44/69d7cfa4b633eae10000000a1553f6/content.htm
Thanks, -
Hello gurus,
Kindly help me in resolving this back ground job problem.
We have a program which gives a tabstrip alv output. they are calling subscreens for this and using containers for alv.
its running good in foreground but going dump in back ground execution.
i have used the code written in forums,
data: or_doc type ref to cl_gui_docking_container .
if cl_gui_alv_grid=>offline( ) is initial.
create object or_custom_container
exporting container_name = c_container.
create object or_grid
exporting i_parent = or_custom_container.
else .
create object or_grid
exporting i_parent = or_doc .
endif .
now the error is ''set screen not allowed in subscreens.''
Could you tell me wats the problem
regards
rajeshHi Sandeep,
Change the 1st statement of your program
REPORT ZALV LINE-SIZE 300.
Specify output device as LOCL or LP01 with format as X_65_255 for 255 character width of output.
If width of ALV output is more than 255 say 325, then create a format in SPAD as X_65_325 & assign the same to ALV.
Best regards,
Prashant -
Is there a way to schedule a ftp job to get/put a certain files?
ThanksHere is a sample $HOME/.netrc file. When you ftp springfield it will automatically login and run the ls command before quitting. Note it needs a blank line at the end to work. See netrc(4) for more info.
machine springfield login homer password simpson
macdef init
ls
quit
Hope that helps,
Ralph
SUN DTS -
Hi All,
Does anyone have experience of setting schedule ftp job with OEM and could give me some hints or an example, thank you very much. I am now using Oracle 9i.
Rds,
CHLucas,
Your first issue is regarding the control file not being passed. In order to fix that you have to specify the control file in the mapping configuration. Beware that this control file is being read through utl_file, i.e. you will have to set the utl_file_dir in the init parameters of your database to the correct directory in order for the database to be able to read it. Basically, the control file is being read in order to fill the audit tables with the correct data.
Your second issue is regarding the type of job. As you may know OWB 'integrates' with Oracle Workflow (OWF) as well. The OWF solution also relies on the use of OEM for job execution. All of that is currently managed by Workflow Queue Listener. In order for Workflow Queue listener to be able to correctly handle the OEM jobs (defined as external functions in OWF) the job has to be defined as is. Besides, with the current way of registering the jobs all jobs (PL/SQL, ABAP or SQL Loader) are registered in the same way and directed by parameters.
Hope this helps,
Mark. -
Question: FTP jobs local user field
Just wanted to get an idea if anyone knows if as a best practice this should be populated or not. We don't have the configuration setting 'FTP Local User Mandatory' checked, but I wonder if it should. I am assuming that if local user is not populated that the agent service account then is what the job runs as.
Everyones security requirements may vary.
I would suggest making it mandatory as a best practice as it forces you to be consistent. Then when that one-off happens and you need to deliver to a "secure" location the RTU id is obvious and not hidden by falling out to the agent service and a different RTU could be used that is permissioned. (we name our RTU and logon accounts for services differently)
We have very few FTP jobs left in Tidal (we have to host our own FTP Solution anyway so we just use its API to send / rec) which will all be retired when we move to 6.X -
Business Objects Enterprise 11.5 FTP Transfer Problem
Hello,
Hopefully someone out there will be familiar with the issue I'm having and be able to provide a solution.
We are running Business Objects Enterprise 11.5 on our Windows 2003 server. I've created and scheduled a job on the server that creates an XLS file containing loan portfolio data that is to be transmitted to a third party client on a monthly basis.
The problem centers around the method of transfer, which is via FTP to a secure site hosted by the client. When executed through Crystal, the FTP actually does achieve a successful login using the credentials the client provided (we have verified this repeatedly by looking at the logs), but the client's server "kicks out" when we attempt any operation on it.
A similar result was produced when we attempted to FTP to the site via the Windows command line. The login was successful, but even a simple command to view the directory "dir" resulted in the connection being rejected. To make a long story short, after reviewing the issue extensively with the client's technical department, our conclusion was that the problem was the result of the FTP sending in "active" mode instead of "passive". We confirmed this by installing a freeware FileZilla on the same server, and switching between active and passive modes (active failed, passive did not).
Their tech people recommended that we contact SAP to get answers to two questions, which I'm hoping someone out there may know:
1) How does Business Objects Enterprise 11.5 execute the FTP process? Is it using its own native logic or simply invoking the command line?
2) Is there any setting with the console that would enable us to modify the FTP settings to send force it to send in passive mode?
Thanks.Hi,
This is a known limitation. BO only supports active mode for FTP. Refer 1782115 - Which FTP mode is supported as a schedule or publication destination for reference.
If you are able to write a batch file or a program object to transfer a file from a file location to Client FTP, you can try the below workaround.
1. Add the script\batch file as a program object in BO. In the script make sure you include the code to delete the instance after it is successfully transmitted through FTP.
2. Create a File event pointing to the location along with the name of the instance.
3. Schedule the report to the file location with the specific instance name.
4. Schedule the program object based on the file event you created in step 2.
Hope this helps.
Regards
Chinmaya -
Getting file from ftp server problem.
Anyone can tell me what's wrong with my code.
I try to get Test.txt from my ftp server with this coding :
public class FTPClient{
public static final void main(String[] args) throws Exception
{ try {
URL url = new URL("ftp://user:password@myhost:21/MyFiles/Test.txt");
URLConnection c = url.openConnection();
BufferedReader r = new BufferedReader(new InputStreamReader(c.getInputStream()));
String l = null;
while ( (l = r.readLine()) != null)
System.out.println(l);
catch (Exception e)
System.out.println("Uh oh, got an IOException error!");
e.printStackTrace();
But i get the following error :
sun.net.ftp.FtpProtocolException: PORT :
at sun.net.ftp.FtpClient.openDataConnection(FtpClient.java:435)
at sun.net.ftp.FtpClient.get(FtpClient.java:550)
at sun.net.www.protocol.ftp.FtpURLConnection.getInputStream(FtpURLConnection.java:382)
at FTPClient.main(FTPClient.java:8)
Can somebody help me,
What's worng with my coding..?
Thanks,I delete the :21 from my code but the same error occured.
I also try this code
FtpClient ftpClient = new FtpClient();
String host ="10.10.10.237";
String username="username";
String password="password";
try
ftpClient.openServer(host); // connect to FTP server
ftpClient.login(username, password); // login
ftpClient.cd("TestFTP");
ftpClient.binary();
InputStream is = ftpClient.get("Test.txt");
ftpClient.closeServer(); //close connectionand I got the same error
sun.net.ftp.FtpProtocolException: PORT :
at sun.net.ftp.FtpClient.openDataConnection(FtpClient.java:435)
at sun.net.ftp.FtpClient.get(FtpClient.java:550)
at Client.main(Client.java:19)
I dont know what is the problem.. I've try to find information about this error on the net, but cannot find anything that can help me... -
Oracle report generation jobs problem
Hiii,
We have installed the Oracle Clinical 4.6 version forms and report server is installed in same server. After installation we tried to submit the job . The job is successfully submitted but the problem is the status of the job is always set o Submitted_RS. We need to resolve this. if any body know the solution plse provide
Thanks in AdvanceHi,
When i used to get only one page the options like facing, continuous facing are disabled. And displays only single page.
These options are enabled only when there are multiple pages in pdf.
One more thing i found that it happens when I first view the report as pdf it displays
all the pages, then i change the display format to csv and again when i change
the format to pdf the problem starts.
And when I will restart the report server service, it works fine again until i wont view it in CSV format.
Message was edited by:
Yogesh -
Hi,
I scheduled a Program for background job running for every 10 minutes.
When i go to SM37 I am seeing all the background jobs, it is creating a newline for every 10 min in the list.
my problem is , Is there any settings to change for showing only one job that means over writing the old job and show the latest job.
Thanks in advance,
fractalAssuming that intention is to monitor jobs that are either failed or active, you can deselect rest of the radio buttons at the selection screen so as to see failed / active jobs.
Other than this, I dont think there is any solution / way to do this. -
Error: Sheduled Backup Job Problem
Dear all.
I've been getting a problem with a scheduled backup job through OEM since yesterday which I'm not able to find out why as it was working fine. When I access OEM I can see that I have a problem execution and when I investigate why it says "Unable to perform the backup because the database is closed". But my db is open for sure and I'm able to execute the backup from RMAN command line normally. I shut my db down and started it up again but didn't work. Does anybody know why this is happening?
OS: Oracle Enterprise Linux 5
DB: Oracle Database 10g
Thanks a lot.**** Job Definition ****
Status: Scheduled
Scheduled: 09-Jun-2009 20:00:00 o'clock GMT-03:00
Repeating: Daily beginning 09-Jun-2009 20:00:00 (because I changed to do tests)
Type: Database Backup
Owner: SYS
Description: Whole Database Backup
Database Connect String: (DESCRIPTION=(ADDRESS_LIST=(ADDR...
Version 10g or higher: YES
Backup Strategy: advanced
Offline Backup: NO
Blackout: NO
Database Name: ORCL
**** Script ****
$rman_script="backup incremental level 0 cumulative device type disk filesperset = 3 tag '%TAG' database;
backup device type disk filesperset = 3 tag '%TAG' archivelog all not backed up;
allocate channel for maintenance type disk;
delete noprompt obsolete device type disk;
release channel;
&br_save_agent_env();
&br_prebackup($l_db_connect_string, $l_is_cold_backup, $l_use_rcvcat, $l_db_10_or_higher, $l_backup_strategy, "TRUE");
my $result = &br_backup();
exit($result); -
Oracle 10.2 on Windows 2003
auto job cannot get data from remote database via dblink. The error message is invalid username / password. The steps is as follows:
1. login as user xxx
2. create a private dblink to remote database.
3. create a job to run every 5 min
this job will have simple select statement: select count(*) from table name@dblinkname
Note: this job belong to the user xxx.
the user xxx has dba privilege to do things.
4.when the job auto-runs, it failed, the log shows invalid login/password.
Apparently, private dblink won't let auto job run.
Any ideas?
SHI,
Actually, I found a problem ad fixed. The dblink has to be created with username/password.
Thanks for the help.could you please close the thread as answered, else it will still as unanswered. THanks for understanding. -
Hi I am using a ftp class (known as FTPConnection) that i found on this site: http://www.nsftools.com/tips/JavaFtp.htm , and they only have an example of how to download a File through FTP and not upload one. I am in the proccess of making an FTP upload applet, and need some help on getting upload to work. I also need it to work on both a Pc and mac, so that may be attributing to the problem becuase i am currently on a mac which uses file:// instead of C:\\. Ill post the ftp class, and a snippet of my code that tries to upload a selected file.
FTPConnection
/* <!-- in case someone opens this in a browser... --> <pre> */
* File: FTPConnection.java
* Author: Bret Taylor <[email protected]>
* URL: http://www.stanford.edu/~bstaylor/cs/ftpconnection/FTPConnection.java.shtml
* see also <a href="http://www.nsftools.com/tips/JavaFtp.htm">http://www.nsftools.com/tips/JavaFtp.htm</a>
* $Id$
* Parts of this code were adopted from a variety of other FTP classes the
* author has encountered that he was not completely satisfied with. If you
* think more thanks are due to any particular author than is given, please
* let him know. With that caveat, this class can be freely distributed and
* modified as long as Bret Taylor is given credit in the source code comments.
* Modified by Julian Robichaux -- http://www.nsftools.com
* Added constructors, logout(), listFiles(), listSubdirectories(), getAndParseDirList(),
* processFileListCommand(), and overloaded getFullServerReply().
* Also added StringBuffer parameter options to transferData() and executeDataCommand()
* and did a few other little things.
import java.io.*;
import java.net.*;
import java.util.*;
* <p>A wrapper for the network and command protocols needed for the most common
* FTP commands. Standard usage looks something like this:</p>
* <pre> FTPConnection connection = new FTPConnection();
* try {
* if (connection.connect(host)) {
* if (connection.login(username, password)) {
* connection.downloadFile(serverFileName);
* connection.uploadFile(localFileName);
* connection.disconnect();
* } catch (UnknownHostException e) {
* // handle unknown host
* } catch (IOException e) {
* // handle I/O exception
* }</pre>
* <p>Most FTP commands are wrapped by easy-to-use methods, but in case clients
* need more flexibility, you can execute commands directly using the methods
* <a href="#executeCommand(java.lang.String)">executeCommand</a> and
* <a href="#executeDataCommand(java.lang.String,
* java.io.OutputStream)">executeDataCommand</a>,
* the latter of which is used for commands that require an open data port.</p>
* @author Bret Taylor
* @author Julian Robichaux
* @version 1.01
public class FTPConnection extends Object {
* If this flag is on, we print out debugging information to stdout during
* execution. Useful for debugging the FTP class and seeing the server's
* responses directly.
private static boolean PRINT_DEBUG_INFO = false;
* The socket through which we are connected to the FTP server.
private Socket connectionSocket = null;
private String username;
private String password;
private String host;
* The socket output stream.
private PrintStream outputStream = null;
* The socket input stream.
private BufferedReader inputStream = null;
* The offset at which we resume a file transfer.
private long restartPoint = 0L;
* Added by Julian: If this flag is on, we're currently logged in to something.
private boolean loggedIn = false;
* Added by Julian: This is the line terminator to use for multi-line responses.
public String lineTerm = "\n";
* Added by Julian: This is the size of the data blocks we use for transferring
* files.
private static int BLOCK_SIZE = 4096;
* Added by Julian: After you create an FTPConnection object, you will call the
* connect() and login() methods to access your server. Please don't forget to
* logout() and disconnect() when you're done (it's only polite...).
public FTPConnection ()
// default constructor (obviously) -- this is just good to have...
* Added by Julian: Allows you to specify if you want to send debug output to
* the console (true if you do, false if you don't).
public FTPConnection (boolean debugOut)
PRINT_DEBUG_INFO = debugOut;
public FTPConnection (String user, String pw, String host_)
username=user;
password=pw;
host=host_;
PRINT_DEBUG_INFO = false;
* Prints debugging information to stdout if the private flag
* <code>PRINT_DEBUG_INFO</code> is turned on.
private void debugPrint(String message) {
if (PRINT_DEBUG_INFO) System.err.println(message);
* Connects to the given FTP host on port f, the default FTP port.
public boolean connect(String host)
throws UnknownHostException, IOException
return connect(host, 21);
* Connects to the given FTP host on the given port.
public boolean connect(String host, int port)
throws UnknownHostException, IOException
connectionSocket = new Socket(host, port);
connectionSocket.setSoTimeout(10000);
outputStream = new PrintStream(connectionSocket.getOutputStream());
inputStream = new BufferedReader(new
InputStreamReader(connectionSocket.getInputStream()));
if (!isPositiveCompleteResponse(getServerReply())){
disconnect();
return false;
return true;
* Disconnects from the host to which we are currently connected.
static boolean URLexists(String URLName)
try
HttpURLConnection.setFollowRedirects(false);
// note : you may also need
// HttpURLConnection.setInstanceFollowRedirects(false)
HttpURLConnection con =
(HttpURLConnection) new URL(URLName).openConnection();
con.setRequestMethod("HEAD");
return (con.getResponseCode() == HttpURLConnection.HTTP_OK);
catch (Exception e)
e.printStackTrace();
return false;
public String getSimpleFileName(File f)
String path=f.getPath();
String fileName=path.replace("\\", "/");
int slashPos = fileName.lastIndexOf("/");
fileName=fileName.substring(slashPos+1);
return fileName;
public String verifyFileName(String name)
int count=0;
//String url="http://chris-malcolm.com/images/"+URLEncoder.encode(name).replace("+", "%20");
while (URLexists("http://chris-malcolm.com/images/"+URLEncoder.encode(name).replace("+", "%20"))==true)
count++;
name=FileExt(name)[0]+"-"+count+"."+FileExt(name)[1];
return name;
public String[] FileExt(String fileName)
int dotPos = fileName.lastIndexOf(".");
fileName=fileName.replace("\\", "/");
int slashPos = fileName.lastIndexOf("/");
String extension, name;
if (slashPos==fileName.length()-1)
fileName=fileName.substring(0, fileName.length()-1);
slashPos=fileName.lastIndexOf("/");
extension="/";
name=fileName.substring(slashPos+1);
else if(dotPos==-1)
name=fileName.substring(slashPos+1);
extension="";
else
extension = fileName.substring(dotPos+1);
name=fileName.substring(slashPos+1, dotPos);
String[] output={name, extension};
return output;
String[] output={name, extension};
return output;
public void disconnect()
if (outputStream != null) {
try {
if (loggedIn) { logout(); };
outputStream.close();
inputStream.close();
connectionSocket.close();
} catch (IOException e) {}
outputStream = null;
inputStream = null;
connectionSocket = null;
* Wrapper for the commands <code>user [username]</code> and <code>pass
* [password]</code>.
public boolean login(String username, String password)
throws IOException
int response = executeCommand("user " + username);
if (!isPositiveIntermediateResponse(response)) return false;
response = executeCommand("pass " + password);
loggedIn = isPositiveCompleteResponse(response);
return loggedIn;
* Added by Julian: Logout before you disconnect (this is good form).
public boolean logout()
throws IOException
int response = executeCommand("quit");
loggedIn = !isPositiveCompleteResponse(response);
return !loggedIn;
* Wrapper for the command <code>cwd [directory]</code>.
public boolean changeDirectory(String directory)
throws IOException
int response = executeCommand("cwd " + directory);
return isPositiveCompleteResponse(response);
* Wrapper for the commands <code>rnfr [oldName]</code> and <code>rnto
* [newName]</code>.
public boolean renameFile(String oldName, String newName)
throws IOException
int response = executeCommand("rnfr " + oldName);
if (!isPositiveIntermediateResponse(response)) return false;
response = executeCommand("rnto " + newName);
return isPositiveCompleteResponse(response);
* Wrapper for the command <code>mkd [directory]</code>.
public boolean makeDirectory(String directory)
throws IOException
int response = executeCommand("mkd " + directory);
return isPositiveCompleteResponse(response);
* Wrapper for the command <code>rmd [directory]</code>.
public boolean removeDirectory(String directory)
throws IOException
int response = executeCommand("rmd " + directory);
return isPositiveCompleteResponse(response);
* Wrapper for the command <code>cdup</code>.
public boolean parentDirectory()
throws IOException
int response = executeCommand("cdup");
return isPositiveCompleteResponse(response);
* Wrapper for the command <code>dele [fileName]</code>.
public boolean deleteFile(String fileName)
throws IOException
int response = executeCommand("dele " + fileName);
return isPositiveCompleteResponse(response);
* Wrapper for the command <code>pwd</code>.
public String getCurrentDirectory()
throws IOException
String response = getExecutionResponse("pwd");
StringTokenizer strtok = new StringTokenizer(response);
// Get rid of the first token, which is the return code
if (strtok.countTokens() < 2) return null;
strtok.nextToken();
String directoryName = strtok.nextToken();
// Most servers surround the directory name with quotation marks
int strlen = directoryName.length();
if (strlen == 0) return null;
if (directoryName.charAt(0) == '\"') {
directoryName = directoryName.substring(1);
strlen--;
if (directoryName.charAt(strlen - 1) == '\"')
return directoryName.substring(0, strlen - 1);
return directoryName;
* Wrapper for the command <code>syst</code>.
public String getSystemType()
throws IOException
return excludeCode(getExecutionResponse("syst"));
* Wrapper for the command <code>mdtm [fileName]</code>. If the file does
* not exist, we return -1;
public long getModificationTime(String fileName)
throws IOException
String response = excludeCode(getExecutionResponse("mdtm " + fileName));
try {
return Long.parseLong(response);
} catch (Exception e) {
return -1L;
* Wrapper for the command <code>size [fileName]</code>. If the file does
* not exist, we return -1;
public long getFileSize(String fileName)
throws IOException
String response = excludeCode(getExecutionResponse("size " + fileName));
try {
return Long.parseLong(response);
} catch (Exception e) {
return -1L;
* Wrapper for the command <code>retr [fileName]</code>.
public boolean downloadFile(String fileName)
throws IOException
return readDataToFile("retr " + fileName, fileName);
* Wrapper for the command <code>retr [serverPath]</code>. The local file
* path to which we will write is given by <code>localPath</code>.
public boolean downloadFile(String serverPath, String localPath)
throws IOException
return readDataToFile("retr " + serverPath, localPath);
* Wrapper for the command <code>stor [fileName]</code>.
public boolean uploadFile(String fileName)
throws IOException
return writeDataFromFile("stor " + fileName, fileName);
* Wrapper for the command <code>stor [localPath]</code>. The server file
* path to which we will write is given by <code>serverPath</code>.
public boolean uploadFile(String serverPath, String localPath)
throws IOException
return writeDataFromFile("stor " + serverPath, localPath);
* Set the restart point for the next download or upload operation. This
* lets clients resume interrupted uploads or downloads.
public void setRestartPoint(int point)
restartPoint = point;
debugPrint("Restart noted");
* Gets server reply code from the control port after an ftp command has
* been executed. It knows the last line of the response because it begins
* with a 3 digit number and a space, (a dash instead of a space would be a
* continuation).
private int getServerReply()
throws IOException
return Integer.parseInt(getFullServerReply().substring(0, 3));
* Gets server reply string from the control port after an ftp command has
* been executed. This consists only of the last line of the response,
* and only the part after the response code.
private String getFullServerReply()
throws IOException
String reply;
do {
reply = inputStream.readLine();
debugPrint(reply);
} while(!(Character.isDigit(reply.charAt(0)) &&
Character.isDigit(reply.charAt(1)) &&
Character.isDigit(reply.charAt(2)) &&
reply.charAt(3) == ' '));
return reply;
* Added by Julian: Returns the last line of the server reply, but also
* returns the full multi-line reply in a StringBuffer parameter.
private String getFullServerReply(StringBuffer fullReply)
throws IOException
String reply;
fullReply.setLength(0);
do {
reply = inputStream.readLine();
debugPrint(reply);
fullReply.append(reply + lineTerm);
} while(!(Character.isDigit(reply.charAt(0)) &&
Character.isDigit(reply.charAt(1)) &&
Character.isDigit(reply.charAt(2)) &&
reply.charAt(3) == ' '));
// remove any trailing line terminators from the fullReply
if (fullReply.length() > 0)
fullReply.setLength(fullReply.length() - lineTerm.length());
return reply;
* Added by Julian: Gets a list of files in the current directory.
public String listFiles()
throws IOException
return listFiles("");
* Added by Julian: Gets a list of files in either the current
* directory, or one specified as a parameter. The 'params' parameter
* can be either a directory name, a file mask, or both (such as
* '/DirName/*.txt').
public String listFiles(String params)
throws IOException
StringBuffer files = new StringBuffer();
StringBuffer dirs = new StringBuffer();
if (!getAndParseDirList(params, files, dirs))
debugPrint("Error getting file list");
return files.toString();
* Added by Julian: Gets a list of subdirectories in the current directory.
public String listSubdirectories()
throws IOException
return listSubdirectories("");
* Added by Julian: Gets a list of subdirectories in either the current
* directory, or one specified as a parameter. The 'params' parameter
* can be either a directory name, a name mask, or both (such as
* '/DirName/Sub*').
public String listSubdirectories(String params)
throws IOException
StringBuffer files = new StringBuffer();
StringBuffer dirs = new StringBuffer();
if (!getAndParseDirList(params, files, dirs))
debugPrint("Error getting dir list");
return dirs.toString();
* Added by Julian: Sends and gets the results of a file list command,
* like LIST or NLST.
private String processFileListCommand(String command)
throws IOException
StringBuffer reply = new StringBuffer();
String replyString;
// file listings require you to issue a PORT command,
// like a file transfer
boolean success = executeDataCommand(command, reply);
if (!success)
return "";
replyString = reply.toString();
// strip the trailing line terminator from the reply
if (reply.length() > 0)
return replyString.substring(0, reply.length() - 1);
} else {
return replyString;
* Added by Julian: Gets a directory list from the server and parses
* the elements into a list of files and a list of subdirectories.
private boolean getAndParseDirList(String params, StringBuffer files, StringBuffer dirs)
throws IOException
// reset the return variables (we're using StringBuffers instead of
// Strings because you can't change a String value and pass it back
// to the calling routine -- changing a String creates a new object)
files.setLength(0);
dirs.setLength(0);
// get the NLST and the LIST -- don't worry if the commands
// don't work, because we'll just end up sending nothing back
// if that's the case
String shortList = processFileListCommand("nlst " + params);
String longList = processFileListCommand("list " + params);
// tokenize the lists we got, using a newline as a separator
StringTokenizer sList = new StringTokenizer(shortList, "\n");
StringTokenizer lList = new StringTokenizer(longList, "\n");
// other variables we'll need
String sString;
String lString;
// assume that both lists have the same number of elements
while ((sList.hasMoreTokens()) && (lList.hasMoreTokens())) {
sString = sList.nextToken();
lString = lList.nextToken();
if (lString.length() > 0)
if (lString.startsWith("d"))
dirs.append(sString.trim() + lineTerm);
debugPrint("Dir: " + sString);
} else if (lString.startsWith("-")) {
files.append(sString.trim() + lineTerm);
debugPrint("File: " + sString);
} else {
// actually, symbolic links will start with an "l"
// (lowercase L), but we're not going to mess with
// those
debugPrint("Unknown: " + lString);
// strip off any trailing line terminators and return the values
if (files.length() > 0) { files.setLength(files.length() - lineTerm.length()); }
if (dirs.length() > 0) { dirs.setLength(dirs.length() - lineTerm.length()); }
return true;
* Executes the given FTP command on our current connection, returning the
* three digit response code from the server. This method only works for
* commands that do not require an additional data port.
public int executeCommand(String command)
throws IOException
outputStream.println(command);
return getServerReply();
* Executes the given FTP command on our current connection, returning the
* last line of the server's response. Useful for commands that return
* one line of information.
public String getExecutionResponse(String command)
throws IOException
outputStream.println(command);
return getFullServerReply();
* Executes the given ftpd command on the server and writes the results
* returned on the data port to the file with the given name, returning true
* if the server indicates that the operation was successful.
public boolean readDataToFile(String command, String fileName)
throws IOException
// Open the local file
RandomAccessFile outfile = new RandomAccessFile(fileName, "rw");
// Do restart if desired
if (restartPoint != 0) {
debugPrint("Seeking to " + restartPoint);
outfile.seek(restartPoint);
// Convert the RandomAccessFile to an OutputStream
FileOutputStream fileStream = new FileOutputStream(outfile.getFD());
boolean success = executeDataCommand(command, fileStream);
outfile.close();
return success;
* Executes the given ftpd command on the server and writes the contents
* of the given file to the server on an opened data port, returning true
* if the server indicates that the operation was successful.
public boolean writeDataFromFile(String command, String fileName)
throws IOException
// Open the local file
RandomAccessFile infile = new RandomAccessFile(fileName, "r");
// Do restart if desired
if (restartPoint != 0) {
debugPrint("Seeking to " + restartPoint);
infile.seek(restartPoint);
// Convert the RandomAccessFile to an InputStream
FileInputStream fileStream = new FileInputStream(infile.getFD());
boolean success = executeDataCommand(command, fileStream);
infile.close();
return success;
* Executes the given ftpd command on the server and writes the results
* returned on the data port to the given OutputStream, returning true
* if the server indicates that the operation was successful.
public boolean executeDataCommand(String command, OutputStream out)
throws IOException
// Open a data socket on this computer
ServerSocket serverSocket = new ServerSocket(0);
if (!setupDataPort(command, serverSocket)) return false;
Socket clientSocket = serverSocket.accept();
// Transfer the data
InputStream in = clientSocket.getInputStream();
transferData(in, out);
// Clean up the data structures
in.close();
clientSocket.close();
serverSocket.close();
return isPositiveCompleteResponse(getServerReply());
* Executes the given ftpd command on the server and writes the contents
* of the given InputStream to the server on an opened data port, returning
* true if the server indicates that the operation was successful.
public boolean executeDataCommand(String command, InputStream in)
throws IOException
// Open a data socket on this computer
ServerSocket serverSocket = new ServerSocket(0);
if (!setupDataPort(command, serverSocket)) return false;
Socket clientSocket = serverSocket.accept();
// Transfer the data
OutputStream out = clientSocket.getOutputStream();
transferData(in, out);
// Clean up the data structures
out.close();
clientSocket.close();
serverSocket.close();
return isPositiveCompleteResponse(getServerReply());
* Added by Julian: Executes the given ftpd command on the server
* and writes the results returned on the data port to the given
* StringBuffer, returning true if the server indicates that the
* operation was successful.
public boolean executeDataCommand(String command, StringBuffer sb)
throws IOException
// Open a data socket on this computer
ServerSocket serverSocket = new ServerSocket(0);
if (!setupDataPort(command, serverSocket)) return false;
Socket clientSocket = serverSocket.accept();
// Transfer the data
InputStream in = clientSocket.getInputStream();
transferData(in, sb);
// Clean up the data structures
in.close();
clientSocket.close();
serverSocket.close();
return isPositiveCompleteResponse(getServerReply());
* Transfers the data from the given input stream to the given output
* stream until we reach the end of the stream.
private void transferData(InputStream in, OutputStream out)
throws IOException
byte b[] = new byte[BLOCK_SIZE];
int amount;
// Read the data into the file
while ((amount = in.read(b)) > 0) {
out.write(b, 0, amount);
* Added by Julian: Transfers the data from the given input stream
* to the given StringBuffer until we reach the end of the stream.
private void transferData(InputStream in, StringBuffer sb)
throws IOException
byte b[] = new byte[BLOCK_SIZE];
int amount;
// Read the data into the StringBuffer
while ((amount = in.read(b)) > 0) {
sb.append(new String(b, 0, amount));
* Executes the given ftpd command on the server and writes the results
* returned on the data port to the given FilterOutputStream, returning true
* if the server indicates that the operation was successful.
private boolean setupDataPort(String command, ServerSocket serverSocket)
throws IOException
// Send our local data port to the server
if (!openPort(serverSocket)) return false;
// Set binary type transfer
outputStream.println("type i");
if (!isPositiveCompleteResponse(getServerReply())) {
debugPrint("Could not set transfer type");
return false;
// If we have a restart point, send that information
if (restartPoint != 0) {
outputStream.println("rest " + restartPoint);
restartPoint = 0;
// TODO: Interpret server response here
getServerReply();
// Send the command
outputStream.println(command);
return isPositivePreliminaryResponse(getServerReply());
* Get IP address and port number from serverSocket and send them via the
* <code>port</code> command to the ftp server, returning true if we get a
* valid response from the server, returning true if the server indicates
* that the operation was successful.
private boolean openPort(ServerSocket serverSocket)
throws IOException
int localport = serverSocket.getLocalPort();
// get local ip address
InetAddress inetaddress = serverSocket.getInetAddress();
InetAddress localip;
try {
localip = inetaddress.getLocalHost();
} catch(UnknownHostException e) {
debugPrint("Can't get local host");
return false;
// get ip address in high byte order
byte[] addrbytes = localip.getAddress();
// tell server what port we are listening on
short addrshorts[] = new short[4];
// problem: bytes greater than 127 are printed as negative numbers
for(int i = 0; i <= 3; i++) {
addrshorts[i] = addrbytes;
if (addrshorts[i] < 0)
addrshorts[i] += 256;
outputStream.println("port " + addrshorts[0] + "," + addrshorts[1] +
"," + addrshorts[2] + "," + addrshorts[3] + "," +
((localport & 0xff00) >> 8) + "," +
(localport & 0x00ff));
return isPositiveCompleteResponse(getServerReply());
* True if the given response code is in the 100-199 range.
private boolean isPositivePreliminaryResponse(int response)
return (response >= 100 && response < 200);
* True if the given response code is in the 300-399 range.
private boolean isPositiveIntermediateResponse(int response)
return (response >= 300 && response < 400);
* True if the given response code is in the 200-299 range.
private boolean isPositiveCompleteResponse(int response)
return (response >= 200 && response < 300);
* True if the given response code is in the 400-499 range.
private boolean isTransientNegativeResponse(int response)
return (response >= 400 && response < 500);
* True if the given response code is in the 500-5ok i tried explaining th eproblem in the previous post, but i apologize if my explanation was poor. anyways, i tried to look into it further by doing a printStackTrace() and believe it may be a read error. here is my new updated snippet, and also a link to a screenshot ([click here for screenshot|http://img143.imageshack.us/my.php?image=picture4qr0.png]) of what the error looks like on my end. it seems like a socket is not being read, or maybe it is initialized properly. Again I apologize if my problem is vague, but I do appreciate your input. thanks.
updated code snippet
public void uploadFiles()
statusLabel.setVisible(true);
errorLabel.setVisible(true);
uploadButton.setVisible(false);
footer.setVisible(false);
holdingPanel.setVisible(false);
pbar.setVisible(true);
pbar = new JProgressBar();
pbar.setMinimum(0);
float Total=0;
for (int i=0; i<fileLengths.size(); i++)
if(((java.lang.Boolean)model.getValueAt(i,1)).toString().equals("true"))
Total+=Float.parseFloat((String)fileLengths.get(i));
pbar.setMaximum((int)Total);
String info="";
try
ftp=new FTPConnection(false);
ftp.connect("ftp.chris-malcolm.com");
if (ftp.login("chrismal", "***"))
statusLabel.setText("Status: Connected.");
info+="Successfully logged in!\n";
info+="System type is: " + ftp.getSystemType()+"\n";
info+="Current directory is: " + ftp.getCurrentDirectory()+"\n";
if (ftp.changeDirectory("/www/images/"))
info+="directory changed to: " + ftp.getCurrentDirectory()+"\n";
try
for (int i=0; i<allFiles.size(); i++)
if(((java.lang.Boolean)model.getValueAt(i,1)).toString().equals("true"))
String f=client.verifyFileName((String)model.getValueAt(i,0));
String f2=""+((File)allFiles.get(i)).getPath();
info+="filename: "+f2+"\n";
if (ftp.uploadFile(f2))
statusLabel.setText("Status: Uploading "+f+" - "+i+" of "+calculateTotalFiles()+" files(s)");
pbar.setValue(Integer.parseInt((String)fileLengths.get(i)));
else
errorLabel.setText("Error occured while uploading"+f2+"\n");
catch(Exception de)
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
de.printStackTrace(pw);
pw.close();
//errorLabel.setText("<html>ERROR:"+sw.toString().replace("\n", "<br>")+"</html>");
info+="Error: "+de.getMessage()+"\n";
info+="Trace: "+sw+"\n";
try { ftp.disconnect(); statusLabel.setText("Status: disconnected.");} catch(Exception e2) {};
else
info+="could not change directory\n";
else
info+="could not login";
catch (Exception e)
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
pw.close();
info+="Error: "+e.getMessage()+"\n";
info+="Trace: "+sw+"\n";
try { ftp.disconnect(); statusLabel.setText("Status: disconnected.");} catch(Exception e2) {};
errorLabel.setText("ERROR:"+info);
JOptionPane.showMessageDialog(this, info, "test", JOptionPane.PLAIN_MESSAGE);
try { ftp.disconnect(); statusLabel.setText("Status: disconnected.");} catch(Exception e2) {};
Edited by: cjm771 on Jul 13, 2008 7:23 PM -
Help needed in backgroung job problem ?
Hi All,
I scheduled VF31 txn in a background to email the invoices. Now the problem is, when suppose,
if i have 10 invoices and the third invoice doesnt have an mail address....job gets failed..
what i need is even if the third invoice fails i want the job to continued with the fourth invoice.
can anyone help me in this regard.
Thanks.> I scheduled VF31 txn in a background to email the invoices. Now the problem is, when suppose,
> if i have 10 invoices and the third invoice doesnt have an mail address....job gets failed..
> what i need is even if the third invoice fails i want the job to continued with the fourth invoice.
> can anyone help me in this regard.
This means you are may be standard SAP is issuing the error messag when there is no email id on the invoice. Please have a look at the print program for the output type and make sure dont issue any error message if there is no email id. -
hi every one,
pls help me out in this.
i have written a program to create a wbs element.as it takes 20 to 30 min to create one element in production.in my program, there is part of code which creates wbs elements.
so i want to run tht part of code in background.
only part of code.
even i did the coding for it. i wrote a new program and i pasted that part of code in new program.
and this new program i m submitting in old one by creating a back ground job.
i m exporting few required internal tables for new report.i hav imported all internal tables in new report also..
but still this importing exporting is not happening..pls
tell me wat can be the problem..
thanks..Your code is not optimized according to performance,can you sed me your code ...
see my business card for my id.
Thanks
Maybe you are looking for
-
Mac Book Air vs HD video editing
Does anyone know if the MBA can do HD video editing with okay speed? I will choose the 1.86 processor, but is it not depended on the graphic card? What is your experience with this? Karsten
-
Quantum Gateway Router - Local DNS not working
I just installed the Quantum Gateway Router, and I can't seem to get local DNS (i.e. user defined DNS entries) to work correctly. I'm able to make user-defined entries under Advanced->DNS Server, but the when I attempt to ping the entries, from any
-
I'm trying to recreate the 'Recently Added' playlist that featured in the old ipods (4th gen.?) where it stored the songs you've just added to the ipod and each time you plugged it in it would replace the songs in that list with the new ones you've j
-
Please answer me fast , Thank you
-
How to define "User defined" palette in IMAQ Display?
When I select the "User defined" palette in the display, it just shows the regular grayscale palette. I want to replace this with the "Rainbow" palette but slightly modified in range. How do I do this? Thanks! MK Solved! Go to Solution.