Sponsored Content
Full Discussion: Trouble with Nested Ifs
Top Forums Shell Programming and Scripting Trouble with Nested Ifs Post 302132095 by ProFiction on Wednesday 15th of August 2007 09:18:28 AM
Old 08-15-2007
Trouble with Nested Ifs

What I thought was going to be very simple has turned out to be really lame, and so I come to you for help.

Code:
mountedon=`df -k /synctest | awk 'NR == 2 {print $1}'`
if [ $mountedon -ne "ids4:/nex02/synctest" ]
then
   # mount /pupcl06
   mountedon=`df -k /synctest | awk 'NR == 2 {print $1}'`
   if [ $mountedon -ne "ids4:/nex02/synctest" ]
   then
      mailx -s "nightly sync FAILED - check drive mountings" name@email.com name2@email.com << EOH
         drive 'synctest' is not mounted properly.
      EOH
      echo mounting error
      break
   else
      echo successfully mounted
      # wmsynctest
   fi
else
   echo was previously mounted
   # wmsynctest
fi
echo yerp

Note: lines are commented out because I don't want this to actually do anything yet.

Basically, I'm trying to check to see if a drive is mounted properly. If it is, execute another script. If not, try to mount it. If that fails, kill the process. If it succeeds, execute another script.

When I run this program, I get an unexpected end of file error. I'm assuming it's related to the nested ifs because of similar errors I read about online.

So if you know how to get around this problem with the ifs, please let me know. Thank you.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

IFS variable

How can I set the value for IFS variable (2 Replies)
Discussion started by: mahabunta
2 Replies

2. Shell Programming and Scripting

problem with IFS

hi, :) I set IFS=":" But when i try to echo $IFS,i am not getting any thing on the screen escept a blank line. any help pls. cheers RRK (11 Replies)
Discussion started by: ravi raj kumar
11 Replies

3. UNIX for Dummies Questions & Answers

Help on IFS command!

Hi! I am working in korn shell. I want to reset the dimiliter for the set command to "|" but instead of a command prompt return I am getting something as below After issuing the command I am getting this....as if the shell is expecting something else. Can anybody suggest what's the problem. ... (2 Replies)
Discussion started by: udiptya
2 Replies

4. Shell Programming and Scripting

Shell nested ifs

Hi can someone tell me whats wrong with the following: #!/bin/sh file1=$1 file2=$2 if then if then echo "File 1 is" $file1 echo "File 2 is" $file2 cp $file1 $file2 echo "Copy complete!" else echo "ERROR: File does not exist!" ... (8 Replies)
Discussion started by: philmetz
8 Replies

5. Shell Programming and Scripting

regarding IFS=

hi i am a learner can some explain "export IFS=$(echo "\n\t\a")" i am not able to understand the functionality please help thanks Satya (1 Reply)
Discussion started by: Satyak
1 Replies

6. Shell Programming and Scripting

while loop with 3 ifs

im messing up somehwere...and can't seem to clean up the script...for it to work objectives: 1. check for today's file, and sleep 30 secs between retries 2. only allow 5 tries before script should fail. 3. if today's file found, wait 30 seconds for it to process.. code: count=0... (8 Replies)
Discussion started by: sigh2010
8 Replies

7. Shell Programming and Scripting

read and IFS

Hi, This is out of curiosity: I wanted to extract year, month and date from a variable, and thought that combining read and IFS would help, but this doesn't work: echo "2010 10 12" | read y m d I could extract the parts of the date when separated by a -, and setting IFS in a subshell: ... (3 Replies)
Discussion started by: raphinou
3 Replies

8. Shell Programming and Scripting

How to use IFS in this scenario?

Given the scenario like this, if at all if have to use IFS on the below given example, how it should be used. IFS=/ eg: /xyz/123/348/file1 I want to use the last slash /file1 . So can anyone, suggest me how to pick the last "/" as a IFS. (4 Replies)
Discussion started by: raghunsi
4 Replies

9. UNIX for Dummies Questions & Answers

How to use nested ifs in unix?

how to use nested ifs in unix (1 Reply)
Discussion started by: pratima.kumari
1 Replies

10. Shell Programming and Scripting

Nested ifs

hi I keep getting an error with this nested if statement and am getting the error unexpected end of file, can anyone help me as to why this wont execute? #!/bin/bash #script to check wether the -i -v statements run correctly removeFile () { mv $1 $HOME/deleted }... (3 Replies)
Discussion started by: somersetdan
3 Replies
IGAWK(1)							 Utility Commands							  IGAWK(1)

NAME
igawk - gawk with include files SYNOPSIS
igawk [ all gawk options ] -f program-file [ -- ] file ... igawk [ all gawk options ] [ -- ] program-text file ... DESCRIPTION
Igawk is a simple shell script that adds the ability to have ``include files'' to gawk(1). AWK programs for igawk are the same as for gawk, except that, in addition, you may have lines like @include getopt.awk in your program to include the file getopt.awk from either the current directory or one of the other directories in the search path. OPTIONS
See gawk(1) for a full description of the AWK language and the options that gawk supports. EXAMPLES
cat << EOF > test.awk @include getopt.awk BEGIN { while (getopt(ARGC, ARGV, "am:q") != -1) ... } EOF igawk -f test.awk SEE ALSO
gawk(1) Effective AWK Programming, Edition 1.0, published by the Free Software Foundation, 1995. AUTHOR
Arnold Robbins (arnold@skeeve.com). Free Software Foundation Nov 3 1999 IGAWK(1)
All times are GMT -4. The time now is 09:25 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy