- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Shell script that executes FTP in cronjob
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
Discussions
Discussions
Discussions
Forums
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
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
тАО04-08-2004 08:33 PM
тАО04-08-2004 08:33 PM
Currently I have 2 servers (Pluto & Mercury).
I want to ftp a file (abc.unl) from pluto to mercury every morning at 9:00am. So, is there any script that can ftp this file through cronjob? I already know how to set the cronjob but just not sure about the script only.
regards.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-08-2004 08:45 PM
тАО04-08-2004 08:45 PM
Re: Shell script that executes FTP in cronjob
Run the script on Pluto.
The script should be:
Name of the script: ftp.sh
Contents of the script:
#!/usr/bin/ksh
PATH=${PATH}:(make it as per your requirement)
export PATH
SERVER=`hostname`
ftp -i -n -v mercury << EOF
user root root123(password of root)
lcd /ss
put abc.unl
bye
EOF
You can use any user other than root too.
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-08-2004 08:51 PM
тАО04-08-2004 08:51 PM
Re: Shell script that executes FTP in cronjob
if you don't want to put the file into the user's home dir then you have to insert a
cd /dir
before the put.
greetings,
Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-08-2004 08:53 PM
тАО04-08-2004 08:53 PM
Re: Shell script that executes FTP in cronjob
A better way might be to use scp. By distributing the public key, you can copy files without using the password.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-08-2004 08:55 PM
тАО04-08-2004 08:55 PM
Re: Shell script that executes FTP in cronjob
#
/usr/bin/ftp -vn mercury <
user
asc
lcd
cd
put
bye
EOM
/usr/bin/grep -q "^[45]" /tmp/ftp.log
if [ $? = 0 ]
then
echo "Errors found. Check FTP log"
exit 1
else
exit 0
fi
# end of script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-08-2004 09:12 PM
тАО04-08-2004 09:12 PM
Re: Shell script that executes FTP in cronjob
Still hv some questions.
Let said the file (abc.unl) in pluto is at /tmp/jr and I want to ftp to mercury /tmp/jr as well.
1) Inside the script, I need to put this line as well??? #!/usr/bin/ksh
What does it means?
2) For my case, means that PATH=${PATH}:(make it as per your requirement) should be PATH=$/tmp/jr ?
3) What is this command means? lcd /ss
Can I put other path?
regards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-08-2004 09:40 PM
тАО04-08-2004 09:40 PM
Re: Shell script that executes FTP in cronjob
let me clarify it.
What Sanjiv posted is a ftp script within a korn shell script.
#!/usr/bin/ksh
means this script is to be run by korn shell
You do not need the PATH statement, if you explicitely run all commands with full path.
lcd sets the local directory to get the file from.
cd sets the directory on the remote host to put the file to.
you can specify any existing directories on your hosts as long as you have the necessary rights.
greetings,
Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-08-2004 10:03 PM
тАО04-08-2004 10:03 PM
Re: Shell script that executes FTP in cronjob
#!/usr/bin/ksh
ftp -i -n -v mercury << EOF
user
asc
lcd /tmp/jr
cd /tmp/jr
put abc.unl
bye
EOF
1) What is asc stands for?
2) If I want to ftp more than 1 file, I need to key in bin and then follow by prompt. Then I can use mput command, right. So, where should I put in the bin and prompt command? Btw, what are bin and prompt stand for?
3) Is bye and quit command same? I think in FTP, we should use bye, right?
4) What is the difference among EOF, EOM and EOD?
regards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-09-2004 02:53 AM
тАО04-09-2004 02:53 AM
Solution2. bin - see 1. If you don't want prompts when transferring multiple files (using mput) add -i in the ftp command line. E.g. ftp -i -n -v hostname.
3. bye and quit do the same thing.
4. In the examples, EOM and EOD are start and end markers for the ftp commands. It could be any text string.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-11-2004 02:41 PM
тАО04-11-2004 02:41 PM
Re: Shell script that executes FTP in cronjob
Inside the script, we need to determine whether the script is executed by Korn or POSIX. Example: #! /usr/bin/ksh
Is there any setting that we can make to enable every script that we write will be executed by POSIX shell script only without specify inside the script?
regards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-11-2004 03:18 PM
тАО04-11-2004 03:18 PM
Re: Shell script that executes FTP in cronjob
The difference is there in the shell. POSIX shell is the default shell from HPUX 10.2 and above. POSX shell is /usr/bin/sh while the Korn shell is /usr/bin/ksh.
By default, the script gets executed in the POSIX shell or the shell defined to the user.
With best wishes
Naveej
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-11-2004 03:32 PM
тАО04-11-2004 03:32 PM
Re: Shell script that executes FTP in cronjob
What you mean is actually there is no different either the script was executed by POSIX or Korn. The result is still the same. Am I right?
regards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-11-2004 05:00 PM
тАО04-11-2004 05:00 PM
Re: Shell script that executes FTP in cronjob
Yes exactly, i don't find any difference in the way features that POSIX and KORN shells have. Both has command history, command line editing, arithematic evaluation, coprocess facility....
The root user's shell is the posix shell always, as there is no /sbin/ksh..
regds
Naveej