Control machine and check value


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Control machine and check value
# 1  
Old 05-16-2015
Control machine and check value

I'm thinking how to control and execute command to control my machine like update them,
scenario is creating a cron in machine 1 machine 2 machine 3 which download .txt file from core machine,
this txt file contain update function like:
Code:
kernel=1
yum=0
ssl=1

and store this file in /etc/update.txt

then this cron check if in update.txt file, kernel=1 then execute yum update kernel , if yum=1 then execute yum update and if ssl=0 do nothing,
is it possible (or any replacement idea)

how can i write check part, (if kernel = 1 then ... )

Last edited by vbe; 05-16-2015 at 12:01 PM.. Reason: code tag - typos
# 2  
Old 05-16-2015
It you're running bash (or other recent shell), try
Code:
. /etc/update.txt
while IFS="=" read MOD REST; do echo -n "$MOD "; (( $MOD )) && echo update || echo keep; done < /etc/update.txt
kernel update
yum keep
ssl update

---------- Post updated at 17:21 ---------- Previous update was at 17:19 ----------

Or even just
Code:
while IFS="=" read MOD YESNO; do echo -n "$MOD "; (( $YESNO )) && echo update || echo keep; done < /etc/update.txt

# 3  
Old 05-16-2015
Quote:
Originally Posted by RudiC
It you're running bash (or other recent shell), try
Code:
. /etc/update.txt
while IFS="=" read MOD REST; do echo -n "$MOD "; (( $MOD )) && echo update || echo keep; done < /etc/update.txt
kernel update
yum keep
ssl update

---------- Post updated at 17:21 ---------- Previous update was at 17:19 ----------

Or even just
Code:
while IFS="=" read MOD YESNO; do echo -n "$MOD "; (( $YESNO )) && echo update || echo keep; done < /etc/update.txt

can you explain how it work?
remember that i want to change update.txt file every week ,like set kernel=1 or 0 in certain time
# 4  
Old 05-16-2015
Exactly. Change /etc/update.txt and run above; it will do what is requested. It reads the file line by line and executes a function or script if value equals 1. Above is a skeleton to show how it's doable; you'll need to define the actions yourself.
# 5  
Old 05-16-2015
Code:
export REMOTKERNEL=$( /usr/bin/curl -s  http://xxxx/kernel.txt )
export REMOTYUM=$( /usr/bin/curl -s  http://xxxx/yum.txt )
if [ $REMOTKERNEL == 0 ]; then
        echo "NO update"
else
        yum update kernel*
        echo "Upgrade completed"
fi
if [ $REMOTYUM == 0 ]; then
        echo "NO update"
else
        yum update -y
        echo "Upgrade completed"
fi

how about this function ?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to check everything are migrated after the physical to vmware virtual machine?

I have a physical machine , just use vmware tools migrated data to virtual machine . how can I check these two servers - old and new server , the data are the same , all files are copy to new server ? thanks (2 Replies)
Discussion started by: ust3
2 Replies

2. UNIX for Advanced & Expert Users

How do we check the Linux machine OS?

I have IBM Z-Linux machine as well as RedHat Linux. Where do I see that the particular machine is z-Linux? below output from zlinux. $ uname -a Linux xxxxxxxHostname 2.6.18-406.el5 #1 SMP Fri May 1 10:42:26 EDT 2015 s390x s390x s390x GNU/Linux below output from redhat. $ uname -a... (3 Replies)
Discussion started by: govindts
3 Replies

3. Shell Programming and Scripting

Check and control params in parsing file

Hello, I would like to control and check the right parameters $1 must have 4 alphabetics digits among eora qora pora fora $2 must have 2 numerics digits 00 to 11 $3 must have 2 numerics digits 00 to 59 $4 must have 10 characters alpha numerics as 2013-02-26 For example : In case 5) if i... (15 Replies)
Discussion started by: amazigh42
15 Replies

4. Shell Programming and Scripting

Check and control params in parsing file

Hello, I would like to control and check the right parameters $1 must have 4 alphabetics digits among eora qora pora fora $2 must have 2 numerics digits 00 to 11 $3 must have 2 numerics digits 00 to 59 $4 must have 10 characters alpha numerics as 2013-02-26 For example : In case 5) if i... (1 Reply)
Discussion started by: amazigh42
1 Replies

5. Fedora

how to check if autosys or control-M is running?

Hi, On a unix/linux server, how do I check if Autosys or Control-M (scheduler) is running? are there unique processes for these applications that I could do ps -ef | grep ??? thanks, Jason (11 Replies)
Discussion started by: seafan
11 Replies

6. Shell Programming and Scripting

Check file exists on remote machine.

I am haveing one script haveing one issue with this could any one can reply soon it is very urgent. :p if ssh hcp_ftp@$1 'ls '$2/stop.txt' 1>&2 2>/dev/null'; then exit 1; else scp -p hcp_ftp@$1:$2/VAT*.dat $3 <<EOF EOF cd $3 pwd echo 'About to find file' SOURCE_FILE=$(ls -rt VAT*.dat|tail... (2 Replies)
Discussion started by: marpadga18
2 Replies

7. Shell Programming and Scripting

check for a file on a remote machine

Hi, Can someone tell me how to check if a file exists on a remote machine using rexec command?I'm using ksh. Thanks (3 Replies)
Discussion started by: Sheema
3 Replies

8. UNIX for Dummies Questions & Answers

How to automate check outs from version control?

I'm in a fustrating situation where I am repeatidly checking code, editing, synchronizing, finding something is broke, reverting all my changes and starting over. This if often easier than trying to merge my changes with someone who has beat me to the checkin. Is there a way I can mitigate... (5 Replies)
Discussion started by: siegfried
5 Replies

9. SCO

How to check memory details of a SCO UNIXWARE machine

Hi All, I want to check memory details and other hardware details of my SCO machine. can someone please share the command to do that? Thanks, Am (2 Replies)
Discussion started by: am_yadav
2 Replies

10. SCO

Need Script to check whether user exists in the remote machine

Hi All, I am new to shell scripting. Can someone let me know, how to check whether the user exists in the remote system? I am building a new unix box and before I proceed installing the appliation , I want to check whether the required users are created in the system . how to do this ?... (1 Reply)
Discussion started by: Srini75
1 Replies
Login or Register to Ask a Question