- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Shell Scripting
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
12-26-2004 07:45 PM
12-26-2004 07:45 PM
Shell Scripting
i need to implement the following shell scripts and since i am not that good in scripting so i can explain the idea of the scripts and can someone help me get them done.
first script:
create script to run from the cron tab every 5 min to check on the availability of another machine (ping) and in case the ping is not working then this other machine is not live, so change the IP of the running machine to the IP of the failed machine then set a flag that the backup machine is running, so as you will check on it next time the cron tab is perfomrning the script.
Second Script:
the idea is i need to make a backup from one machine, move it to another machine in a specified location, then perform the unbackup on the other machine.
on one machine, i will do something like backup or copy for some folders and files, then i need to copy or ftp or whatever the way to the other machine, in a specific location on this other machine, then i would unbackup, or if i am doing cpy then no operation will be done, i need to do this also in the cron tab every one day and every one week.
thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2004 07:58 PM
12-26-2004 07:58 PM
Re: Shell Scripting
read some doc and after that if you can not find way we will tell you :))
read
#man cron
#man bash
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2004 08:21 PM
12-26-2004 08:21 PM
Re: Shell Scripting
It is advisable to learn some shell scripting first becuase even if any one gives you the readymade script then also you need to customize it according to your environment and even maintain it further.
To start with you can go thr' korn shell scritping on the link below and once you are familiar with korn then it makes little difference with other shells.
http://www.hk8.org/old_web/unix/ksh/index.htm
Also you can learn perl programming which is the most powerful scripting laguage.
http://www.hk8.org/old_web/perl/learn/index.htm
Hope that helps.
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2004 09:06 PM
12-26-2004 09:06 PM
Re: Shell Scripting
as far ur first script is concerned,i couldn't get the idea of changing IP..
i use a script to continually check/ping all my machines in LAN...& i have kept it in cron..
scrip name: pingcheck
#! /bin/sh
(first to check whether cron deamon is running or not)
vard=`ps -aef | grep -v grep | grep cron | wc -l`
if [ $vard = 0 ]
then
logger -p daemon.notice "ERROR: Cron Daemon Killed "
fi
(second keep a ping to other hosts)
ping 137.xx.xx.xxx -n 4 >cpr
cat cpr | grep -v 64 | grep -v Statistics | grep "0%" | grep -v "round" >cpr1
var=`cat cpr1 | awk ' { print $4 }'`
if [ $var = 0 ]
then
logger -p user.err "ERROR: Cannot reach 137.xx.xx.xxx(New host Connectivity)"
fi
(check errors in /var/adm/syslog/syslog.log)
u can extend this script for as many hosts in ur LAN.
u can keep this script in cron to check for every 15 mins for 6 working days..
# crontab -l
00,15,30,45 06-23 * * 1-6 /home/ahmed/pingcheck
[of course u can modify ur crontab :)]
------------------------------------------
for the second script:
it can look like this:
scrip name: f3
#! /bin/sh
cd /dumps/dbdump
ls * >/home/ahmed/f3_tmp
##########################################
for file in `cat /home/ahmed/f3_tmp`
do
echo $file
sleep 2
HOST='137.xx.xx.xx'
USER='ahmed' )user name & password are
PASSWD='xxxxxx' )hardcoded
FILE=`echo $file`
ftp -n $HOST <
quote USER $USER
quote PASS $PASSWD
bin
cd /dumps/dbdump
put /dumps/dbdump/$FILE
quit
END_SCRIPT
#exit 0
done
u can keep this script in cron too..
#crontab -l
00 18 * * 1-6 /home/ahmed/f3
hope this helps..if not then don blame me:D
regards
ABHIK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2004 03:49 AM
12-27-2004 03:49 AM
Re: Shell Scripting
Using ping to check the availability of a system is not a good idea. It is too low in the IP stack. It is possible for a system that is completely hosed to still respond to a ping.
Better is to use remsh or secure shell or something else that requires the remote system to actually do something:
remsh DESTHOST "ls -l /etc/hosts"
Your second question can be done with tar and rcp or scp.
cd DIRECTORY
tar cvf /tmp/tarball .
scp (or rcp) /tmp/tarball DESTINATION:DIRECTORY
ssh (or remsh) DESTINATION "tar xvf DIRECTORY/tarball"
Cron is easy to use. Do "man crontab". It'll tell you all you need.
Chris