- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- script help
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2002 12:13 AM
07-09-2002 12:13 AM
-pDATE.dat
-DDATE.dat
-pkDATE.dat
where date is the current date. So the file has different names every day.
After the ftp these files should be moved to the up directory.
My script actually is:
SPOOLDIR=/data/files/to_send
BKPDIR=/data/files
DESTDIRMK=/data/recieved/mk
DESTDIROP=/data/recieved/op
cd $SPOOLDIR
FTP_FILES
mv *.dat $BKPDIR
FTP_FILES ()
{
echo "####################"
echo "STARTING FTP SESSION"
echo "####################"
ftp -n ipaddress <
ascii
hash
cd $DESTDIR
put .... (files in 2 directories)
bye
eof
}
My problem is how to ftp two files in one directory and the other to another directory.
Thanks in advance for your help.
Tarek
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2002 04:55 AM
07-09-2002 04:55 AM
Re: script help
If the files should be in different directories on the remote system you could use the cd command to change to the other directory. You could also use the put command with the absolute path on both servers (the cd commands would not be needed and you would be ensured that the file is the correct location). However in the instance that the files are in different directories on the local system you would use the lcd command to change the local directory.
Hope this helps.
As a note it is not a secure method to have clear text accounts and passwords in a readable script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2002 05:47 AM
07-09-2002 05:47 AM
Re: script help
About the password i know it's not very secure, but it's not so important.
About the ftp how can i do?
put p* remotedir
put d* remotedir
put pk* remotedir
but does the * work??
As i told, the files will have the same prefix but then they're different.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2002 07:02 AM
07-09-2002 07:02 AM
Re: script help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2002 07:18 AM
07-09-2002 07:18 AM
Re: script help
However, as mentioned above, you can use the mput command within ftp to send multiple files.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2002 07:32 AM
07-09-2002 07:32 AM
Re: script help
You would first send the standard output of the ftp command to a temporary file for later testing. After the ftp session has closed you will go back and check the temp file. This file should contain 3 instances of the successful ftp transfer message (the HPUX server I am connected to now has "Transfer complete"). You should then check the number of instances this message occurs. If it is not 3 then an error message can be sent via e-mail, pager, etc.
However to make these checks accurate you should ensure that only 3 files are being sent. I would put the commands like this:
put $SPOOLDIR/pDATE.dat $DESTDIR/pDATE.dat
put $SPOOLDIR/DDATE.dat $DESTDIR/DDATE.dat
put $SPOOLDIR/pkDATE.dat $DESTDIR/pkDATE.dat
Also note that if this script will be scheduled to run automatically it is not necessary to include hash because that just monitors the traffic.
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2002 07:55 AM
07-09-2002 07:55 AM
Re: script help
In the to_send directory (locally) i only have those 3 files, nothing else... and after ftp i move the files to the up directory so the day after, when these file are generated, in the to_send directory i will only find again 3 files and so on.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2002 11:04 PM
07-09-2002 11:04 PM
SolutionDT=`date +%Y-%m-%d`
This would assign DT value of 2002-07-10 (the format I use; see man date for how to change it).
Then you could do
put d$DT.dat remotedir
which would result in sending file d2002-07-10.dat to remotedir.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2002 08:54 PM
07-14-2002 08:54 PM
Re: script help
Additionally there is a special macro type 'init' which is invoked at login, so if you define this macro name ftp will automatically run the commands in the macro for you.
A sample .netrc file would look like:
machine
login
password
macdef init # defines initial macro - this is run at login
# end macro with null line
macdef getit # a non 'login' macro, invoked from inside ftp by typing $getit at the ftp prompt.
# end macro with null line
A .netrc file must be in the users home directory and have permissions of 400, obviously there are security risks if you choose to include a cleartext login and password for the remote server.
HTH
Steph
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2002 12:12 AM
07-16-2002 12:12 AM
Re: script help
I have another problem with my script. I explain how my script is made. It is composed of two parts, sql and script shell.
I extract data from oracle with sqlplus and this generates the three files, after that i do ftp to move this files.
Now if i run my script manually (sh scriptname.sh) it works fine and everything's go ok, but if i run the same script with crontab it gives me an error:
Message file spl
Error 6 initializing SQL*PLUS
My line in the crontab is:
0 3 * * * sh /tmp/myscript.sh 1>/tmp/myscript'date +'\%y\%m\%d''.log 2>&1
Any hint?
Thanks again.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2002 04:08 AM
07-16-2002 04:08 AM
Re: script help
Run `set` command from the prompt and save the output. Then run `set` from a script from cron and compare the output to the saved one. I think you might see a different PATH variable and maybe some other different or missing ones on the "cron" output. If so, try redefining those in your script.