Need script (1029 Views)
Reply
Regular Advisor
Vishal_1980
Posts: 90
Registered: ‎05-14-2014
Message 1 of 30 (1,029 Views)

Need script

Hello experts--

 

I require one script for file copying from local server to FTP.

 

Thanks ,

 

Vishal

Acclaimed Contributor
Dennis Handly
Posts: 25,063
Registered: ‎03-06-2006
Message 16 of 30 (787 Views)

Re: Need ftp script

[ Edited ]
Acclaimed Contributor
Dennis Handly
Posts: 25,063
Registered: ‎03-06-2006
Message 2 of 30 (990 Views)
Regular Advisor
Vishal_1980
Posts: 90
Registered: ‎05-14-2014
Message 3 of 30 (973 Views)

Re: Need ftp script

Hello : i will explain the scenario,

 

Pls check attacment & suggest me.

Hope some will provide me the solution ,as i am new to scripting.

 

 

Thanks in advance

 

Acclaimed Contributor
Dennis Handly
Posts: 25,063
Registered: ‎03-06-2006
Message 4 of 30 (956 Views)

Re: Need ftp script

[ Edited ]

Any reason you provided an Excel file?  Is this how you need to get your script input of is this just how you wanted to present your requirements?  (Here a text file is better.)

 

If this is a one time thing, you can just code these values in a script.  Or copy the script and change them.

Or you can pass them as parms to the script.

 

#!/usr/bin/ksh

 

# ftp files from SRC_PATH/SRC to TGT on SERVER.  Using USER & PASS

 

SRC_PATH=/usr/sap/RAV/SYS/global/ftp/RMPA

src="RAV_INFO_20*"

TGT=/

SERVER=10.10.10.31

USER=dewqv

PASS="password"

 

ftp -inv $SERVER <<EOF
user $USER $PASS

bin

lcd $SRC_PATH

cd $TGT
mput $src
bye

EOF

Regular Advisor
Vishal_1980
Posts: 90
Registered: ‎05-14-2014
Message 5 of 30 (947 Views)

Re: Need ftp script

Thanks a lot sir.....& sorry for puting the excel ...next time i will remember this definately..

However what if i want multiple file to be transfered from HP-UX to windows box.

As this is for the same purpose.We need to transfer few files more than six files from HP-UX to windows bos.

Please suggest me furthere & once again thanks for the guidence.

 

Regards,

Vishal

Regular Advisor
Vishal_1980
Posts: 90
Registered: ‎05-14-2014
Message 6 of 30 (940 Views)

Re: Need ftp script

Dear sir..

 

I creates the script & run on the test server ....i below is the output ..

 

 

# ./ftpcptest
Connected to 10.10.10.31.
220-FileZilla Server version 0.9.41 beta
220-written by Tim Kosse (Tim.Kosse@gmx.de)
220 Please visit http://sourceforge.net/projects/filezilla/
Remote system type is UNIX.
331 Password required for dewqv
230 Logged on
200 Type set to I
Local directory now /sapmnt/RAV/global/ftp/RMPA
250 CWD successful. "/" is current directory.
(local-files) local: bye remote: bye
bye: No such file or directory
221 Goodbye
#

 

Please suggest .....

 

Thanks

Vishal

Regular Advisor
Vishal_1980
Posts: 90
Registered: ‎05-14-2014
Message 7 of 30 (939 Views)

Re: Need ftp script

Dear sir ,

 

i need to move the below mention file

 

 

# pwd
/usr/sap/RAV/SYS/global/ftp/RMPA
# ll
total 12
-rw-rw----   1 rdvadm     sapsys         146 May 27 15:04 RAV_INFO_20140527_001.PSV
-rw-rw----   1 rdvadm     sapsys        2692 May 27 15:02 RAV_MM_20140527_001.PSV
-rw-rw----   1 rdvadm     sapsys          92 May 27 15:03 RAV_VM_20140527_001.PSV

 

thanks ,

Vishal

Acclaimed Contributor
Dennis Handly
Posts: 25,063
Registered: ‎03-06-2006
Message 8 of 30 (919 Views)

Re: Need ftp script

>I need to move the below mentioned file: RAV_INFO_20140527_001.PSV

 

I assume you only wanted this one?

 

It appears that the forum changed my "src=" to lower case.  It tried to edit it several times and each time it did it again.

So I changed both to "src".

Regular Advisor
Vishal_1980
Posts: 90
Registered: ‎05-14-2014
Message 9 of 30 (911 Views)

Re: Need ftp script

Yes sir..i got that & made the changes now it is successfull.......attached is the output

 

therefore i need to move 6 files at a time (all are different name) what changes i need to do in the script pls suggest...

 

 

Thanks ,

 

Vishal

 

Acclaimed Contributor
Dennis Handly
Posts: 25,063
Registered: ‎03-06-2006
Message 10 of 30 (902 Views)

Re: Need ftp script

>made the changes now it is successful. attached is the output

 

(If you are happy with the answers, please click on the kudos star for each helpful answer.)

 

If you don't want so much output, you can remove that "v" in -inv.

Also, this script doesn't really catch errors too well.

 

>therefore i need to move 6 files at a time (all are different name)

 

Do you have a file matching pattern that will do all 6?

Otherwise you can just include all of them in:

src="file1 file2"

Regular Advisor
Vishal_1980
Posts: 90
Registered: ‎05-14-2014
Message 11 of 30 (866 Views)

Re: Need ftp script

Hello sir, yes i made the changes.However i want to cut paste the files.The requirement is when the files get generated on source it will be cut from their & paste to the destination.
Please suggest...

Thanks & have a great day ahead.
Regards,
Vishal
Acclaimed Contributor
Dennis Handly
Posts: 25,063
Registered: ‎03-06-2006
Message 12 of 30 (855 Views)

Re: Need ftp script

>i want to cut paste the files.

 

(Files don't get cut & pasted, they get copied and then removed.  :-)

 

After the mput you can simply do:

!rm -f $src

 

But since there is no checking for any errors, this may be dangerous.

Regular Advisor
Vishal_1980
Posts: 90
Registered: ‎05-14-2014
Message 13 of 30 (852 Views)

Re: Need ftp script

Thanks a lot sir....yes i am discussing the same with my team & we come to the same conclusion.So how could we do the error checking.Please suggest further.
Regular Advisor
Vishal_1980
Posts: 90
Registered: ‎05-14-2014
Message 14 of 30 (841 Views)

Re: Need ftp script

Will you please guide me: i want to scheduled the program for every 15 min in a day ,for the week & year as well


Thanks in advance .....
Regular Advisor
Vishal_1980
Posts: 90
Registered: ‎05-14-2014
Message 15 of 30 (836 Views)

Re: Need ftp script

I am scheduling by the bellow values:

*/15,*,*,* * * * * /usr/sap/RDV/SYS/global/ftp/RMPA/ftpcptest.sh
Acclaimed Contributor
Dennis Handly
Posts: 25,063
Registered: ‎03-06-2006
Message 17 of 30 (807 Views)

Re: Need ftp script

>for every 15 min in a day, for the week & year

>*/15,*,*,* * * * * /usr/sap/RDV/SYS/global/ftp/RMPA/ftpcptest.sh

 

This is the linux way of doing things.  For HP-UX, you need:

0,15,30,45 * * * * /usr/sap/RDV/SYS/global/ftp/RMPA/ftpcptest.sh

Regular Advisor
Vishal_1980
Posts: 90
Registered: ‎05-14-2014
Message 18 of 30 (786 Views)

Re: Need ftp script

Hello Dennis sir,

I am getting the mail as below.Also there is nothing found in the cron log.
Date: Tue, 10 Jun 2014 09:30:00 +0530 (IST)
From: root@eccdevvg.infodartsap.com
Message-Id: <201406100400.s5A400n3005435@eccdevvg.infodartsap.com>
Subject: cron

sh: /usr/sap/RDV/SYS/global/ftp/RMPA/ftpcptest.sh: not found.


*************************************************
Cron: The previous message is the standard output
and standard error of one of your crontab commands:

/usr/sap/RDV/SYS/global/ftp/RMPA/ftpcptest.sh

Please suggest me on this.

Thanks & regards,
Vishal
Acclaimed Contributor
Dennis Handly
Posts: 25,063
Registered: ‎03-06-2006
Message 19 of 30 (778 Views)

Re: Need ftp script

>sh: /usr/sap/RDV/SYS/global/ftp/RMPA/ftpcptest.sh: not found.

 

Well, is that the path to your script?

Regular Advisor
Vishal_1980
Posts: 90
Registered: ‎05-14-2014
Message 20 of 30 (775 Views)

Re: Need ftp script

Yes sir ,the path is same.However i have to manually execute the script.

Thanks ,
VIshal
Acclaimed Contributor
Dennis Handly
Posts: 25,063
Registered: ‎03-06-2006
Message 21 of 30 (769 Views)

Re: Need ftp script

>I have to manually execute the script.

 

Did you make the script executable?  chmod a+x /usr/sap/RDV/SYS/global/ftp/RMPA/ftpcptest.sh

Regular Advisor
Vishal_1980
Posts: 90
Registered: ‎05-14-2014
Message 22 of 30 (767 Views)

Re: Need ftp script

Yes Dennis sir ,

I made the script executable.
Regular Advisor
Vishal_1980
Posts: 90
Registered: ‎05-14-2014
Message 23 of 30 (765 Views)

Re: Need ftp script

This is the output :
# ll
total 2
-rwxrwxrwx 1 root sys 391 Jun 10 10:35 ftpcptest
Acclaimed Contributor
Dennis Handly
Posts: 25,063
Registered: ‎03-06-2006
Message 24 of 30 (758 Views)

Re: Need ftp script

-rwxrwxrwx 1 root sys 391 Jun 10 10:35 ftpcptest

 

You should NOT make the file writable by everyone nor by group:

chmod go-w ftpcptest

 

If this is local and you're root, this should work, unless you have some unprintable chars in the crontab.

Use vis(1) to check:

crontab -l | vis

Regular Advisor
Vishal_1980
Posts: 90
Registered: ‎05-14-2014
Message 25 of 30 (750 Views)

Re: Need ftp script

[ Edited ]

Hello SIr,

 

The script works good, however when the file is transfer through script the format is different.

And when it is ftp through SAP ftp application the format is different.My customer wants the same format as SAP ftp application.

 

Attaching both the files ,request you to please suggest on this.

The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.