Highlighted
Frequent Contributor.. Frequent Contributor..
Frequent Contributor..
581 views

Unable to run basic FTP script

Jump to solution

I have the following script;

Action()
{
#include "mic_ftp.h"
FTP pFTP;
char * error = 0;
long errId = 0;
pFTP = 0;

ftp_logon_ex (&pFTP,"FTP", "URL=ftp://Me:mypass@myserver.com",LAST);
error = ftp_get_last_error (&pFTP);
errId = ftp_get_last_error_id (&pFTP);

lr_output_message("%ld:%s",errId,error);

ftp_put_ex(&pFTP,"Ftp_Put", "SOURCE_PATH=dummy.txt","TARGET_PATH=/home/Me/dummy.txt",LAST );
error = ftp_get_last_error (&pFTP);
errId = ftp_get_last_error_id (&pFTP);

lr_output_message("%ld:%s",errId,error);

ftp_dir_ex(&pFTP,"Ftp_Dir", "PATH=/home/Me",LAST );

ftp_logout_ex(&pFTP);

return 0;
}

(Excuse the extra get_last_error commands, I wanted to see if there was any other info available). The script is intended to put a file on the server. I am able to do the file PUT with winSCP as well as JMeter, but for some reason the vugen script does not put the file on the server.

As far as the log goes, everything works fine;

Starting action Action.
ftp_receive_buffer : Received response : 220 (vsFTPd 2.0.1)
ftp_receive_buffer : Received response : 331 Please specify the password.
ftp_receive_buffer : Received response : 230 Login successful.
ftp_receive_buffer : Received response : 257 "/home/Me"
Action.c(9): Ftp Logon successful.
Action.c(12): 257:257 "/home/Me
Action.c(13): Ftp Put ended successfully.
Action.c(16): 0:
Action.c(18): Ftp Dir ended successfully.
ftp_receive_buffer : Received response : 221 Goodbye.
Action.c(20): Ftp Session closed successfully.
Ending action Action.

Although I did notice that even if the file to be copied is missing or the target path is wrong, the put still succeeds (which is not helpful at all). I have tried relative and absolute locations for the source and target, and it doesn't make any difference. It's definitely authenticating ok because if I break the username or password the authentication fails. 

I should also mention that I tried the basic FTP commands first (without the _ex extension), with the same outcome. 

What am I missing? Is there something that FTP scripts need to work?

 

 

 

 

0 Likes
1 Solution

Accepted Solutions
Highlighted
Acclaimed Contributor.
Acclaimed Contributor.

1. Functions have a return code, so use that as well.

2. Try the following:

	ret = ftp_put_ex(&pFTP,"Ftp_Put", "SOURCE_PATH=pre_cci.c",ENDITEM, LAST );

Note the ENDITEM, its in the documentation of the ftp_put() and ftp_put_ex() function, but it is not in the example of the ftp_put_ex() function.

It is always dangerous to program by example.

Signature:
Reward community members who take time to respond and help.

View solution in original post

2 Replies
Highlighted
Acclaimed Contributor.
Acclaimed Contributor.

1. Functions have a return code, so use that as well.

2. Try the following:

	ret = ftp_put_ex(&pFTP,"Ftp_Put", "SOURCE_PATH=pre_cci.c",ENDITEM, LAST );

Note the ENDITEM, its in the documentation of the ftp_put() and ftp_put_ex() function, but it is not in the example of the ftp_put_ex() function.

It is always dangerous to program by example.

Signature:
Reward community members who take time to respond and help.

View solution in original post

Highlighted
Frequent Contributor.. Frequent Contributor..
Frequent Contributor..

The return code didn't give any additional information, but adding the ENDITEM allowed the command to work. Time to raise a support ticket to get the example fixed.

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.