Hello everybody, I finally can make a FTP conection and upload the txt file, but I have another problem, hehehehe!
First I made a shell (".sh" file) to configure the proces that conect to the FTP server
Second in my ".p" file I run the ".sh" through the next sentence:
OS-COMMAND SILENT VALUE("query/ventas/ventas_ftp.sh user password file reference").
as you can see in the instruction first I run the ventas_ftp.sh, next I write some variables (user, password, file's name and a reference)
Well, the problem is when I run the .sh file, the variables that I put in the last instrucion don't pass to the .sh file. Anyone knows what can be happening?
** When I do this in my testing environment they work perfectly, but when I change the parameter to conect to the real FTP server the variables don't pass!!
here is the code about the .sh file
echo 'FTP Starts .. ' $4
ftp -n 01.01.01.01 << FIN
user $1 $2
lcd /query/ventas
put $3
quit
FIN
echo 'End ftp'
In fact, I can see that the variables didn't pass beacuse in my .p file i make an OUTPUT fiel to have a log and know about what happen with the ftp conection
this is the code to my .p file
OUTPUT TO VALUE("query/ventas/LogErr.txt") APPEND.
PUT SKIP(1) STRING(TODAY, "99/99/9999") FORMAT "X(10)" " " STRING(TIME, "HH:MM:SS") SKIP.
OS-COMMAND SILENT VALUE("query/ventas/ventas_ftp.sh user password file reference").
OUTPUT CLOSE.
What errors show up in your log file?
It doesn't show me any log, just don't make the conection to the FTP server, when the .sh dile try to do the instruction it says "Login failed."
also as you can see in the .sh configuration I put a text that say
echo 'FTP Starts .. ' $4
and the variable 4 isn't display in the log, so that's way i guess that the variables are no passing
the funny thing about that is that when I do exactlly the same in my testing FTP server everyting is OK no error is there, but just I change the IP Host of my FTP server and de variables are missing. So to give a temporal solution to it I wrote the variables user and password, directly in the .sh file and it works perfect. But I'll like to do it as same as the testing environment anyway with that solution it works ok and for the moment I will do it like that, hehehehe.
In the onther hand, Now I also try to catch an error, in case that the conection doesn't can run, I mean something like define a variable in the .sh file and return it to my .p file to indentify if the FTP process was OK, and send an e-mail reporting that. But I don't know how to make an out variable in the .sh file, o how can I confirm that the FTP process was right.
I'm trying this in the same .p file that runs the .sh file, I just add this code:
DEF VAR vcodigo AS CHARACTER NO-UNDO.
DEF VAR vcorreos AS CHARACTER NO-UNDO.
DEF VAR vTXT AS CHARACTER NO-UNDO.
vTXT = "/var/www/html/ejemplo.txt".
OUTPUT TO VALUE(vTXT).
PUT UNFORMAT 'Testing Email' SKIP.
OUTPUT CLOSE.
vcorreos = 'exemple@xxx.com'.
vcodigo = '$ ps aux | mail -s "Title Mail" ' + vcorreos + '
UNIX SILENT VALUE(vcodigo).
The FTP process runs perfect, but in the email code the log show this
/usr/bin/ksh: $: not found.
:S
do you know what does it mean?
P.S.- Sorry about my english I try to do it as best as I can
The leading "$" doesn't belong in your vcodigo variable. It should be:
vcodigo = 'ps aux | mail -s "Title Mail" ' + vcorreos + '
Is this really what your code says:
OUTPUT TO VALUE("query/ventas/LogErr.txt") APPEND.
PUT SKIP(1) STRING(TODAY, "99/99/9999") FORMAT "X(10)" " " STRING(TIME, "HH:MM:SS") SKIP.
OS-COMMAND SILENT VALUE("query/ventas/ventas_ftp.sh user password file reference").
OUTPUT CLOSE.
Is the path to the script really relative to $PATH? (No leading "/" or "./"?)
Are user, password, file and reference literal text? Or are they Progress variables that you want to be passed to the shell script like this:
vuser = "username".
vpassword = "password".
vfile = "filename".
vreference = "reference".
OUTPUT TO VALUE("query/ventas/LogErr.txt") APPEND.
PUT SKIP(1) STRING(TODAY, "99/99/9999") FORMAT "X(10)" " " STRING(TIME, "HH:MM:SS") SKIP.
OS-COMMAND SILENT VALUE( substitute( "query/ventas/ventas_ftp.sh &1 &2 &3 &4", vuser, vpassword, vfile, vreference )).
OUTPUT CLOSE.
Additionally, when debugging these sorts of things I find it helpful to write the shell script like this:
#!/bin/sh
#
echo 'FTP Starts .. ' $*
echo "arg1 = [${1}] arg1 = [${2}] arg1 = [${3}] arg1 = [${4}]"
ftp -n 01.01.01.01 <
user $1 $2
lcd /query/ventas
put $3
quit
FIN
echo 'End ftp'
The first line ensures that the proper shell is used to run the script.
The "[" around the variables helps to identify extra blanks where I maybe didn't mean for them to be.
I change the text of the 1st echo line when I change the script to makke sure that the proper copy of it is running.
I would also add a trailing PUT to the Progress code that terminates the log file so that you know when control is passed back to the Progress program.
Yes they are literal variables:
this is my code in the .p file
OUTPUT TO VALUE("/pgm/ventas/LogErr.txt") APPEND.
PUT SKIP(1) STRING(TODAY, "99/99/9999") FORMAT "X(10)" " " STRING(TIME, "HH:MM:SS") SKIP.
OS-COMMAND SILENT VALUE("/pgm/ventas/blackberry/ventas_ftp.sh user passwrod Daily(AllStores).txt VentasBlackBerry").
OUTPUT CLOSE.
and this is my .sh file
echo 'Starts FTP ... ' $4
ftp -n 10.21.68.91 <
use r$1 $2
lcd /pgm/ventas/blackberry
put $3
quit
FIN
echo 'Ends ftp'
It try the code that you've written but it doesn't work
the log show this
/usr/bin/ksh: 0403-057 Syntax error at line 1 : `(' is not expected.
Unix shells don't like "(" in file names. If that is really the filename you need to escape the "(" and ")" like so:
OS-COMMAND SILENT VALUE("/pgm/ventas/blackberry/ventas_ftp.sh user passwrod Daily~\(AllStores~\).txt VentasBlackBerry").
(The "\" escapes it for the unix shell, but since that is also a Progress escape character you need the "~" to escape the "\" for Progress. Yes, it's kind of confusing.)
Is the same
It works OK with the "~\" that you say, in testing environment works perfect but when I change the parameters to the other FTP server, the variables don't pass to the .sh file look this is the log error with the code that you wrote:
FTP Starts .. user
arg1 = [ftpbby] arg1 = [] arg1 = [] arg1 = []
User user cannot log in.
Login failed.
View File
Local directory now /pgm/ventas/blackberry
(local-file) (remote-file) usage:put local-file remote-file
End ftp
I give up heheheh
My guess is that there are disallowed characters in the string after the user name. You will have to post the real commands for anyone to make sense of it though.
Yes I was thinking about that, and I also made some test. And that it, beacuse de password starts with "#" caracter, and has more special caracters, so I erase just the password variable and works perfect.
Sooooo... finally I decide just send the name of file, the reference like variables, and the user and passwrod I'll write them directly in the .sh file
and that's it now everything works OK !!!
So thanks a lot for your help, it really was good!! thanks a lot!!
do you have mail, for future question, hehehehehehe just a joke take care!!!
"#" is the shell comment character -- everything on the line after the "#" is ignored.