"Help with bash script" - "License Server and Patch Updates"


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers "Help with bash script" - "License Server and Patch Updates"
# 15  
Old 03-28-2014
profileuser, I have refrained from giving you a fifth warning for code tags so far because any more warning points would set your account read-only for a month. Please at least try.

Moderator's Comments:
Mod Comment To keep the forums high quality for all users, please take the time to format your posts correctly.

First of all, use Code Tags when you post any code or data samples so others can easily read your code. You can easily do this by highlighting your code and then clicking on the # in the editing menu. (You can also type code tags [code] and [/code] by hand.)



Second, avoid adding color or different fonts and font size to your posts. Selective use of color to highlight a single word or phrase can be useful at times, but using color, in general, makes the forums harder to read, especially bright colors like red.

Third, be careful when you cut-and-paste, edit any odd characters and make sure all links are working property.

Thank You.

The UNIX and Linux Forums
# 16  
Old 03-28-2014
Thanks guys. Now I see...

Normal text / words goes outside..

Code:
go goes here

Thanks for this youtube tutorial.. very informative.
# 17  
Old 04-01-2014
Hi Guys,

Could you please help diagnose the syntax the script below is refering:

Code:
[root@xen01 ~]# vi ./postscript.sh
[root@xen01 ~]# ./postscript.sh
-bash: ./postscript.sh: Permission denied
[root@xen01 ~]# chmod 755 ./postscript.sh
[root@xen01 ~]# ./postscript.sh
./postscript.sh: line 5: if[ -a /tmp/secondboot ]: No such file or directory
./postscript.sh: line 6: syntax error near unexpected token `then'
./postscript.sh: line 6: `then'
[root@xen01 ~]#

The full script written in vi is below:

Code:
[root@xen01 ~]# vi ./postscript.sh
#!/bin/bash
# Install XenServer Updates
HOSTUUID=$(xe host-list name-label=$HOSTNAME --minimal)
cd /tmp
if[ -a /tmp/secondboot ]
then
        echo "Secondboot"
else
        mkdir updates
        cd updates
        echo"Downloading updates..."
        wget ftp://192.168.10.5/FTP/xen62/*.xsupdate
        cd /tmp
        touch /tmp/secondboot
fi
for updatefile in 'ls /tmp/updates';do
        echo sleeping in 60 secs
        sleep 60
        echo "Uploading Update $updatefile..."
        echo "Uploading Update $Updatefile...">> /var/log/messages
        PATCHUUID=$(xe patch-upload file-name=/tmp/Updates/$updatefile)
        sleep 10
        echo "installing Update $updatefile..."
        echo "installing update $updatefile...">> /var/log/messages
        xe patch-apply host-uuid=$HOSTUUID uuid=$PATCHUUID
        rm -f /tmp/updates/$updatefile
        PATCHACTION=$(xe patch-list uuid=$PATCHUUID params=after-apply-guidance --minimal)
        if[ "$PATCHACTION"=="restartXAPI" ]
then
        /opt/xensource/bin/xe-toolstack-restart
        sleep 60
elif [ "$PATCHACTION"=="restartHost" ]; then
        reboot;
        sleep 60
fi
done
# Disable first boot for subsequent reboots
rm -f /etc/rc3.d/S99zzpostinstall
rm -f /tmp/secondboot
# Final Reboot
reboot

---------- Post updated at 02:16 PM ---------- Previous update was at 01:55 PM ----------

Hi Guys,

what file or directory is it referring ?

syntax near unexpected token; what does this mean ?
# 18  
Old 04-01-2014
Give space after "if" statement

Code:
if [ -a /tmp/secondboot ]


Last edited by npandith; 04-01-2014 at 11:00 AM.. Reason: use code tags please even for so little!
# 19  
Old 04-01-2014
Thanks Npandith,

I'll try that now and get back to you.

---------- Post updated at 05:10 PM ---------- Previous update was at 05:00 PM ----------

Hi Npandith,

You did it,

The last syntax error given now is the 'then' on line 29', what does this mean ?


Code:
[root@xen01 ~]# ./postscript.sh
./postscript.sh: line 11: echoDownloading updates...: command not found
--2014-04-01 17:06:07--  ftp://192.168.10.5/FTP/xen62/*.xsupdate
           => `.listing'
Connecting to 192.168.10.5:21... connected.
Logging in as anonymous ... Logged in!
==> SYST ... done.    ==> PWD ... done.
==> TYPE I ... done.  ==> CWD /FTP/xen62 ... done.
==> PASV ... done.    ==> LIST ... done.

    [ <=>                                                                                                                           ] 951         --.-K/s   in 0.005s

2014-04-01 17:06:08 (169 KB/s) - `.listing' saved [951]

Removed `.listing'.
--2014-04-01 17:06:08--  ftp://192.168.10.5/FTP/xen62/XS62E001.xsupdate
           => `XS62E001.xsupdate'
==> CWD not required.
==> PASV ... done.    ==> RETR XS62E001.xsupdate ... done.
Length: 6625641 (6.3M)

100%[==============================================================================================================================>] 6,625,641   --.-K/s   in 0.1s

2014-04-01 17:06:08 (58.0 MB/s) - `XS62E001.xsupdate' saved [6625641]

--2014-04-01 17:06:08--  ftp://192.168.10.5/FTP/xen62/XS62E002.xsupdate
           => `XS62E002.xsupdate'
==> CWD not required.
==> PASV ... done.    ==> RETR XS62E002.xsupdate ... done.
Length: 1743501 (1.7M)

100%[==============================================================================================================================>] 1,743,501   --.-K/s   in 0.08s

2014-04-01 17:06:08 (20.1 MB/s) - `XS62E002.xsupdate' saved [1743501]

--2014-04-01 17:06:08--  ftp://192.168.10.5/FTP/xen62/XS62E004.xsupdate
           => `XS62E004.xsupdate'
==> CWD not required.
==> PASV ... done.    ==> RETR XS62E004.xsupdate ... done.
Length: 35766769 (34M)

100%[==============================================================================================================================>] 35,766,769  58.8M/s   in 0.6s

2014-04-01 17:06:09 (58.8 MB/s) - `XS62E004.xsupdate' saved [35766769]

--2014-04-01 17:06:09--  ftp://192.168.10.5/FTP/xen62/XS62E005.xsupdate
           => `XS62E005.xsupdate'
==> CWD not required.
==> PASV ... done.    ==> RETR XS62E005.xsupdate ... done.
Length: 9315631 (8.9M)

100%[==============================================================================================================================>] 9,315,631   32.8M/s   in 0.3s

2014-04-01 17:06:09 (32.8 MB/s) - `XS62E005.xsupdate' saved [9315631]

--2014-04-01 17:06:09--  ftp://192.168.10.5/FTP/xen62/XS62E010.xsupdate
           => `XS62E010.xsupdate'
==> CWD not required.
==> PASV ... done.    ==> RETR XS62E010.xsupdate ... done.
Length: 252927 (247K)

100%[==============================================================================================================================>] 252,927     --.-K/s   in 0.003s

2014-04-01 17:06:09 (77.5 MB/s) - `XS62E010.xsupdate' saved [252927]

--2014-04-01 17:06:09--  ftp://192.168.10.5/FTP/xen62/XS62E011.xsupdate
           => `XS62E011.xsupdate'
==> CWD not required.
==> PASV ... done.    ==> RETR XS62E011.xsupdate ... done.
Length: 845698 (826K)

100%[==============================================================================================================================>] 845,698     --.-K/s   in 0.02s

2014-04-01 17:06:09 (48.0 MB/s) - `XS62E011.xsupdate' saved [845698]

--2014-04-01 17:06:09--  ftp://192.168.10.5/FTP/xen62/XS62E012.xsupdate
           => `XS62E012.xsupdate'
==> CWD not required.
==> PASV ... done.    ==> RETR XS62E012.xsupdate ... done.
Length: 35767767 (34M)

100%[==============================================================================================================================>] 35,767,767  48.6M/s   in 0.7s

2014-04-01 17:06:10 (48.6 MB/s) - `XS62E012.xsupdate' saved [35767767]

--2014-04-01 17:06:10--  ftp://192.168.10.5/FTP/xen62/XS62E014.xsupdate
           => `XS62E014.xsupdate'
==> CWD not required.
==> PASV ... done.    ==> RETR XS62E014.xsupdate ... done.
Length: 1745433 (1.7M)

100%[==============================================================================================================================>] 1,745,433   --.-K/s   in 0.04s

2014-04-01 17:06:10 (43.6 MB/s) - `XS62E014.xsupdate' saved [1745433]

--2014-04-01 17:06:10--  ftp://192.168.10.5/FTP/xen62/XS62ESP1002.xsupdate
           => `XS62ESP1002.xsupdate'
==> CWD not required.
==> PASV ... done.    ==> RETR XS62ESP1002.xsupdate ... done.
Length: 1744985 (1.7M)

100%[==============================================================================================================================>] 1,744,985   --.-K/s   in 0.04s

2014-04-01 17:06:10 (40.4 MB/s) - `XS62ESP1002.xsupdate' saved [1744985]

./postscript.sh: line 29: syntax error near unexpected token `then'
./postscript.sh: line 29: `then'

---------- Post updated at 05:14 PM ---------- Previous update was at 05:10 PM ----------

So apparently, the script has downloaded the updates however it has not applied the patched yet.

seems a long way to go yet in trouble shooting this script in order to apply the patches to the server.

Please assist whereever you can
# 20  
Old 04-01-2014
Code:
 PATCHACTION=$(xe patch-list uuid=$PATCHUUID params=after-apply-guidance --minimal) 
if  [ "$PATCHACTION"=="restartXAPI" ]
then
        /opt/xensource/bin/xe-toolstack-restart
        sleep 60
elif [ "$PATCHACTION"=="restartHost" ]; then
        reboot;
        sleep 60
fi
done

# 21  
Old 04-01-2014
Add spaces:

Now:
Code:
if[ "$PATCHACTION"=="restartXAPI" ]

After:
Code:
if [ "$PATCHACTION" == "restartXAPI" ]


EDIT:
VBS was faster typing Smilie
BTW: Same goes for the ELIF below.

hth
 
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. AIX

Apache 2.4 directory cannot display "Last modified" "Size" "Description"

Hi 2 all, i have had AIX 7.2 :/# /usr/IBMAHS/bin/apachectl -v Server version: Apache/2.4.12 (Unix) Server built: May 25 2015 04:58:27 :/#:/# /usr/IBMAHS/bin/apachectl -M Loaded Modules: core_module (static) so_module (static) http_module (static) mpm_worker_module (static) ... (3 Replies)
Discussion started by: penchev
3 Replies

2. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

3. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

4. Shell Programming and Scripting

how to use "cut" or "awk" or "sed" to remove a string

logs: "/home/abc/public_html/index.php" "/home/abc/public_html/index.php" "/home/xyz/public_html/index.php" "/home/xyz/public_html/index.php" "/home/xyz/public_html/index.php" how to use "cut" or "awk" or "sed" to get the following result: abc abc xyz xyz xyz (8 Replies)
Discussion started by: timmywong
8 Replies

5. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

6. Shell Programming and Scripting

Simplify Bash Script Using "sed" Or "awk"

Input file: 2 aux003.net3.com error12 6 awn0117.net1.com error13 84 aux008 error14 29 aux001.ha.ux.isd.com error12 209 aux002.vm.ux.isd.com error34 21 alx0027.vm.net2.com error12 227 dux001.net5.com error123 22 us008.dot.net2.com error121 13 us009.net2.com error129Expected Output: 2... (4 Replies)
Discussion started by: sQew
4 Replies

7. Shell Programming and Scripting

cat $como_file | awk /^~/'{print $1","$2","$3","$4}' | sed -e 's/~//g'

hi All, cat file_name | awk /^~/'{print $1","$2","$3","$4}' | sed -e 's/~//g' Can this be done by using sed or awk alone (4 Replies)
Discussion started by: harshakusam
4 Replies

8. UNIX for Dummies Questions & Answers

Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`"

Hi Friends, Can any of you explain me about the below line of code? mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'` Im not able to understand, what exactly it is doing :confused: Any help would be useful for me. Lokesha (4 Replies)
Discussion started by: Lokesha
4 Replies
Login or Register to Ask a Question