LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-23-2016, 11:25 AM   #31
linuxnewbie0101
Member
 
Registered: Dec 2015
Posts: 46

Original Poster
Rep: Reputation: Disabled

ok guys im back again, for some reason, only the -m argument works and will backup all user jobs from crontab.

not sure why -p and -u tag are not working. it just backup all users job from the crontab even if i provide a new path or user to backup.

any thoughts.

TY
 
Old 06-23-2016, 11:26 AM   #32
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,258

Rep: Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947
Add print statements to see if those variables are getting set
 
1 members found this post helpful.
Old 06-23-2016, 11:30 AM   #33
michaelk
Moderator
 
Registered: Aug 2002
Posts: 14,930

Rep: Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520
In addition, if still running in debug mode (set -xv) you should be able to see if the $location and $user variables are being set and how your program loops through all of the conditional statements.

Post the output.

If you fixed the done statements as keefaz suggested yesterday the p and u options should get assigned.

Last edited by michaelk; 06-23-2016 at 11:40 AM.
 
Old 06-23-2016, 11:47 AM   #34
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 5,387

Rep: Reputation: 397Reputation: 397Reputation: 397Reputation: 397
Quote:
Originally Posted by linuxnewbie0101 View Post
possible to provide an example of functions?
Not tested, just to give idea:
Code:
function setBackupDir() 
{
  [[ -z $location ]] && bkuplocation="$location"
  [[ ! -d $bkuplocation ]] && mkdir -p "$bkuplocation"
}

function backup()
{
  if [[ -z "$user" ]]; then
    cp $cron_source/* "$bkuplocation"
  else
    crontab -l -u $user > "$bkuplocation/$user"
  fi
}

function restore()
{
  if [[ -z "$user" ]]; then
    for i in $bkuplocation/*; do 
      myUser=${i##*/}
      if ! id "$myUser" > /dev/null; then
        echo "Not a valid user: $myUser"
        exit 1 # or continue maybe?
      fi
      crontab "$i"
    done
  else
    if [[ ! -f $bkuplocation/$user ]]; then
      echo "No crontab file for $user to restore"
      exit 1
    fi
  crontab "$bkuplocation/$user"
  fi
}

Last edited by keefaz; 06-23-2016 at 11:53 AM.
 
1 members found this post helpful.
Old 06-23-2016, 11:58 AM   #35
linuxnewbie0101
Member
 
Registered: Dec 2015
Posts: 46

Original Poster
Rep: Reputation: Disabled
so i've modified the code since yesterday. so here it is, TY

Code:
#!/bin/bash
set -xv

bkuplocation="/systems/homes/cronjobs_bk"
cron_source="/var/spool/cron/crontabs"
host=$(hostname -s)

#Help function
function show_help {
  echo " Command line switches -m is required, -p & -u are optional."
  echo " -m  --Sets the value for option to backup or restore (backup/restore)."
  echo " -p  --(OPTIONAL) Sets the path to backup from and restore to."
  echo " -u  --(OPTIONAL) Sets the user jobs to backup."
  echo " -h  --Displays this help message. No further functions are performed."
  exit 1
}

#Check the number of arguments. If none are passed, print help and exit.
numargs=$#
if [ $numargs -eq 0 ]; then
  show_help
fi

# Start getopts code
while getopts m:puh options; do
  case $options in
    m) 
      method=$OPTARG
      ;;
    p) 
      location=$OPTARG
      ;;
    u)
      user=$OPTARG
      ;;
    h)
      show_help
      ;;
  \?) echo -e "Option $OPTARG not allowed."
      show_help
      ;;
  esac

done

cd $cron_source

if [[ ! -z $location ]]; then
  $backuplocation=$location
else 
  $location=$bkuplocation
fi



case $method in
  backup)
    if [[ ! -d $bkuplocation/$host ]]; then
      mkdir $bkuplocation/$host
    fi
    if [[ -z $user ]]; then
      cd $cron_source
      for i in *; do 
        crontab -l -u $i > $bkuplocation/$host/$i
      done
    elif [[ ! -z $user ]]; then
        crontab -l -u $user > $bkuplocation/$host/$user
    else 
      show_help
    fi
  ;;

  restore)
    if [[ ! -d $bkuplocation ]]; then
	echo "no backup found for $host"
    fi
    if [[ -z $user ]]; then
      cd $bkuplocation/$host/$i
      for i in *; do
        crontab $i
      done  
    elif [[ ! -z $user ]]; then
        crontab $user < $bkuplocation/$host/$user
    else
      show_help
    fi
  ;;
esac

case $location in
  '')
    $location=$bkuplocation
  ;;
  "*") 
    $location=$OPTARG
  ;;
esac

case $user in
  '')
  ;;
  *) 
    $user=$OPTARG
  ;;
esac

shift $((OPTIND-1))

exit 0

and here is the output from setting xv

the command that i ran

sudo ./getopt.sh -m backup -p /var/log -u root

for some reason it continues to backup all users files to my $bkuplocation even when i call it different place and user


Code:
bkuplocation="/systems/homes/cronjobs_bk"
+ bkuplocation=/systems/homes/cronjobs_bk
cron_source="/var/spool/cron/crontabs"
+ cron_source=/var/spool/cron/crontabs
host=$(hostname -s)
hostname -s
++ hostname -s
+ host=mysql11

#Help function
function show_help {
  echo " Command line switches -m is required, -p & -u are optional."
  echo " -m  --Sets the value for option to backup or restore (backup/restore)."
  echo " -p  --(OPTIONAL) Sets the path to backup from and restore to."
  echo " -u  --(OPTIONAL) Sets the user jobs to backup."
  echo " -h  --Displays this help message. No further functions are performed."
  exit 1
}

#Check the number of arguments. If none are passed, print help and exit.
numargs=$#
+ numargs=6
if [ $numargs -eq 0 ]; then
  show_help
fi
+ '[' 6 -eq 0 ']'

# Start getopts code
while getopts m:puh options; do
  case $options in
    m) 
      method=$OPTARG
      ;;
    p) 
      location=$OPTARG
      ;;
    u)
      user=$OPTARG
      ;;
    h)
      show_help
      ;;
  \?) echo -e "Option $OPTARG not allowed."
      show_help
      ;;
  esac

done
+ getopts m:puh options
+ case $options in
+ method=backup
+ getopts m:puh options
+ case $options in
+ location=
+ getopts m:puh options

cd $cron_source
+ cd /var/spool/cron/crontabs

if [[ ! -z $location ]]; then
  $backuplocation=$location
else 
  $location=$bkuplocation
fi
+ [[ ! -z '' ]]
+ =/systems/homes/cronjobs_bk
./getopt.sh: line 51: =/systems/homes/cronjobs_bk: No such file or directory



case $method in
  backup)
    if [[ ! -d $bkuplocation/$host ]]; then
      mkdir $bkuplocation/$host
    fi
    if [[ -z $user ]]; then
      cd $cron_source
      for i in *; do 
        crontab -l -u $i > $bkuplocation/$host/$i
      done
    elif [[ ! -z $user ]]; then
        crontab -l -u $user > $bkuplocation/$host/$user
    else 
      show_help
    fi
  ;;

  restore)
    if [[ ! -d $bkuplocation ]]; then
	echo "no backup found for $host"
    fi
    if [[ -z $user ]]; then
      cd $bkuplocation/$host/$i
      for i in *; do
        crontab $i
      done  
    elif [[ ! -z $user ]]; then
        crontab $user < $bkuplocation/$host/$user
    else
      show_help
    fi
  ;;
esac
+ case $method in
+ [[ ! -d /systems/homes/cronjobs_bk/mysql11 ]]
+ [[ -z '' ]]
+ cd /var/spool/cron/crontabs
+ for i in '*'
+ crontab -l -u mysql
+ for i in '*'
+ crontab -l -u root

case $location in
  '')
    $location=$bkuplocation
  ;;
  "*") 
    $location=$OPTARG
  ;;
esac
+ case $location in
+ =/systems/homes/cronjobs_bk
./getopt.sh: line 92: =/systems/homes/cronjobs_bk: No such file or directory

case $user in
  '')
  ;;
  *) 
    $user=$OPTARG
  ;;
esac
+ case $user in

shift $((OPTIND-1))
+ shift 3

exit 0
+ exit 0
 
Old 06-23-2016, 12:13 PM   #36
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,258

Rep: Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947
You removed the colons next to p and u...the colon is what tells getopts that the flag has an argument. I covered this in post #19 and you had it right in your debug output in post #22, why did you change it?

http://wiki.bash-hackers.org/howto/getopts_tutorial

Last edited by suicidaleggroll; 06-23-2016 at 12:21 PM.
 
1 members found this post helpful.
Old 06-23-2016, 12:22 PM   #37
linuxnewbie0101
Member
 
Registered: Dec 2015
Posts: 46

Original Poster
Rep: Reputation: Disabled
used the code from yesterday, it still will not pick up the -p and -u and continues to backup all users job




Code:
#!/bin/bash
set -xv

bkuplocation="/systems/homes/cronjobs_bk"
cron_source="/var/spool/cron/crontabs"
host=$(hostname -s)

#Help function
function show_help {
  echo " Command line switches -m is required, -p & -u are optional."
  echo " -m  --Sets the value for option to backup or restore (backup/restore)."
  echo " -p  --(OPTIONAL) Sets the path to backup from and restore to."
  echo " -u  --(OPTIONAL) Sets the user jobs to backup."
  echo " -h  --Displays this help message. No further functions are performed."
  exit 1
}

#Check the number of arguments. If none are passed, print help and exit.
numargs=$#
if [ $numargs -eq 0 ]; then
  show_help
fi

# Start getopts code
while getopts m:p:u:h options; do
  case $options in
    m) 
      method=$OPTARG
      ;;
    p) 
      location=$OPTARG
      ;;
    u)
      user=$OPTARG
      ;;
    h)
      show_help
      ;;
  \?) echo -e "Option $OPTARG not allowed."
      show_help
      ;;
  esac

done

cd $cron_source

if [[ ! -z $location ]]; then
  $backuplocation=$location
else 
  $location=$bkuplocation
fi



case $method in
  backup)
    if [[ ! -d $bkuplocation/$host ]]; then
      mkdir $bkuplocation/$host
    fi
    if [[ -z $user ]]; then
      cd $cron_source
      for i in *; do 
        crontab -l -u $i > $bkuplocation/$host/$i
      done
    elif [[ ! -z $user ]]; then
        crontab -l -u $user > $bkuplocation/$host/$user
    else 
      show_help
    fi
  ;;

  restore)
    if [[ ! -d $bkuplocation ]]; then
	echo "no backup found for $host"
    fi
    if [[ -z $user ]]; then
      cd $bkuplocation/$host/$i
      for i in *; do
        crontab $i
      done  
    elif [[ ! -z $user ]]; then
        crontab $user < $bkuplocation/$host/$user
    else
      show_help
    fi
  ;;
esac

case $location in
  '')
    $location=$bkuplocation
  ;;
  "*") 
    $location=$OPTARG
  ;;
esac

case $user in
  '')
  ;;
  *) 
    $user=$OPTARG
  ;;
esac

shift $((OPTIND-1))

exit 0

output

Code:
~$ sudo ./getopt.sh -m backup -p /var/log -u root

bkuplocation="/systems/homes/cronjobs_bk"
+ bkuplocation=/systems/homes/cronjobs_bk
cron_source="/var/spool/cron/crontabs"
+ cron_source=/var/spool/cron/crontabs
host=$(hostname -s)
hostname -s
++ hostname -s
+ host=mysql11

#Help function
function show_help {
  echo " Command line switches -m is required, -p & -u are optional."
  echo " -m  --Sets the value for option to backup or restore (backup/restore)."
  echo " -p  --(OPTIONAL) Sets the path to backup from and restore to."
  echo " -u  --(OPTIONAL) Sets the user jobs to backup."
  echo " -h  --Displays this help message. No further functions are performed."
  exit 1
}

#Check the number of arguments. If none are passed, print help and exit.
numargs=$#
+ numargs=6
if [ $numargs -eq 0 ]; then
  show_help
fi
+ '[' 6 -eq 0 ']'

# Start getopts code
while getopts m:p:u:h options; do
  case $options in
    m) 
      method=$OPTARG
      ;;
    p) 
      location=$OPTARG
      ;;
    u)
      user=$OPTARG
      ;;
    h)
      show_help
      ;;
  \?) echo -e "Option $OPTARG not allowed."
      show_help
      ;;
  esac

done
+ getopts m:p:u:h options
+ case $options in
+ method=backup
+ getopts m:p:u:h options
+ case $options in
+ location=/var/log
+ getopts m:p:u:h options
+ case $options in
+ user=root
+ getopts m:p:u:h options

cd $cron_source
+ cd /var/spool/cron/crontabs

if [[ ! -z $location ]]; then
  $backuplocation=$location
else 
  $location=$bkuplocation
fi
+ [[ ! -z /var/log ]]
+ =/var/log
./getopt.sh: line 49: =/var/log: No such file or directory



case $method in
  backup)
    if [[ ! -d $bkuplocation/$host ]]; then
      mkdir $bkuplocation/$host
    fi
    if [[ -z $user ]]; then
      cd $cron_source
      for i in *; do 
        crontab -l -u $i > $bkuplocation/$host/$i
      done
    elif [[ ! -z $user ]]; then
        crontab -l -u $user > $bkuplocation/$host/$user
    else 
      show_help
    fi
  ;;

  restore)
    if [[ ! -d $bkuplocation ]]; then
	echo "no backup found for $host"
    fi
    if [[ -z $user ]]; then
      cd $bkuplocation/$host/$i
      for i in *; do
        crontab $i
      done  
    elif [[ ! -z $user ]]; then
        crontab $user < $bkuplocation/$host/$user
    else
      show_help
    fi
  ;;
esac
+ case $method in
+ [[ ! -d /systems/homes/cronjobs_bk/mysql11 ]]
+ [[ -z root ]]
+ [[ ! -z root ]]
+ crontab -l -u root

case $location in
  '')
    $location=$bkuplocation
  ;;
  "*") 
    $location=$OPTARG
  ;;
esac
+ case $location in

case $user in
  '')
  ;;
  *) 
    $user=$OPTARG
  ;;
esac
+ case $user in
+ root=
./getopt.sh: line 103: root=: command not found

shift $((OPTIND-1))
+ shift 6

exit 0
+ exit 0

Last edited by linuxnewbie0101; 06-23-2016 at 01:10 PM.
 
Old 06-23-2016, 12:26 PM   #38
linuxnewbie0101
Member
 
Registered: Dec 2015
Posts: 46

Original Poster
Rep: Reputation: Disabled
do i need to shift after each of my if/elif/else statement?
 
Old 06-23-2016, 12:27 PM   #39
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,258

Rep: Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947
See post #19 and 36
 
1 members found this post helpful.
Old 06-23-2016, 12:52 PM   #40
michaelk
Moderator
 
Registered: Aug 2002
Posts: 14,930

Rep: Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520
The posted code and the debug output are not the same but take a look at the debug output from post #22,#23 and the comments from post #27.
 
Old 06-23-2016, 01:37 PM   #41
linuxnewbie0101
Member
 
Registered: Dec 2015
Posts: 46

Original Poster
Rep: Reputation: Disabled
so now im only stuck at the -p usage, for some reason $location is not picking up or do i need to have a case statement for '') and *)??

how could i use the argument provided by -p?

i am now able to backup and restore with all user or with -u specified.

Code:
#!/bin/bash
set -xv

bkuplocation="/systems/homes/cronjobs_bk"
cron_source="/var/spool/cron/crontabs"
host=$(hostname -s)

#Help function
function show_help {
  echo " Command line switches -m is required, -p & -u are optional."
  echo " -m  --Sets the value for option to backup or restore (backup/restore)."
  echo " -p  --(OPTIONAL) Sets the path to backup from and restore to."
  echo " -u  --(OPTIONAL) Sets the user jobs to backup."
  echo " -h  --Displays this help message. No further functions are performed."
  exit 1
}

#Check the number of arguments. If none are passed, print help and exit.
numargs=$#
if [ $numargs -eq 0 ]; then
  show_help
fi

# Start getopts code
while getopts :m:p:u:h options; do
  case $options in
    m) 
      method=$OPTARG
      ;;
    p) 
      location=$OPTARG
      ;;
    u)
      user=$OPTARG
      ;;
    h)
      show_help
      ;;
  \?) echo -e "Option $OPTARG not allowed."
      show_help
      ;;
  esac
done

cd $cron_source

#if [[ -z $location ]]; then
#  location=$bkuplocation
#fi

case $method in
  backup)
    if [[ ! -d $bkuplocation/$host ]]; then
      mkdir $bkuplocation/$host
    fi
    if [[ -z $user ]]; then
      cd $cron_source
      for i in *; do 
        crontab -l -u $i > $bkuplocation/$host/$i
      done
    elif [[ ! -z $user ]]; then
        crontab -l -u $user > $bkuplocation/$host/$user
    else 
      show_help
    fi
  ;;

  restore)
    if [[ ! -d $bkuplocation ]]; then
	echo "no backup found for $host"
    fi
    if [[ -z $user ]]; then
      cd $bkuplocation/$host/$i
      for i in *; do
        crontab $i
      done  
    elif [[ ! -z $user ]]; then
        crontab $user < $bkuplocation/$host/$user
    else
      show_help
    fi
  ;;
esac

shift $((OPTIND-1))

exit 0
verbose output

Code:
~$ sudo ./getopt.sh -m backup -p /var/log -u root

bkuplocation="/systems/homes/cronjobs_bk"
+ bkuplocation=/systems/homes/cronjobs_bk
cron_source="/var/spool/cron/crontabs"
+ cron_source=/var/spool/cron/crontabs
host=$(hostname -s)
hostname -s
++ hostname -s
+ host=mysql11

#Help function
function show_help {
  echo " Command line switches -m is required, -p & -u are optional."
  echo " -m  --Sets the value for option to backup or restore (backup/restore)."
  echo " -p  --(OPTIONAL) Sets the path to backup from and restore to."
  echo " -u  --(OPTIONAL) Sets the user jobs to backup."
  echo " -h  --Displays this help message. No further functions are performed."
  exit 1
}

#Check the number of arguments. If none are passed, print help and exit.
numargs=$#
+ numargs=6
if [ $numargs -eq 0 ]; then
  show_help
fi
+ '[' 6 -eq 0 ']'

# Start getopts code
while getopts :m:p:u:h options; do
  case $options in
    m) 
      method=$OPTARG
      ;;
    p) 
      location=$OPTARG
      ;;
    u)
      user=$OPTARG
      ;;
    h)
      show_help
      ;;
  \?) echo -e "Option $OPTARG not allowed."
      show_help
      ;;
  esac
done
+ getopts :m:p:u:h options
+ case $options in
+ method=backup
+ getopts :m:p:u:h options
+ case $options in
+ location=/var/log
+ getopts :m:p:u:h options
+ case $options in
+ user=root
+ getopts :m:p:u:h options

cd $cron_source
+ cd /var/spool/cron/crontabs

#if [[ -z $location ]]; then
#  location=$bkuplocation
#fi

case $method in
  backup)
    if [[ ! -d $bkuplocation/$host ]]; then
      mkdir $bkuplocation/$host
    fi
    if [[ -z $user ]]; then
      cd $cron_source
      for i in *; do 
        crontab -l -u $i > $bkuplocation/$host/$i
      done
    elif [[ ! -z $user ]]; then
        crontab -l -u $user > $bkuplocation/$host/$user
    else 
      show_help
    fi
  ;;

  restore)
    if [[ ! -d $bkuplocation ]]; then
	echo "no backup found for $host"
    fi
    if [[ -z $user ]]; then
      cd $bkuplocation/$host/$i
      for i in *; do
        crontab $i
      done  
    elif [[ ! -z $user ]]; then
        crontab $user < $bkuplocation/$host/$user
    else
      show_help
    fi
  ;;
esac
+ case $method in
+ [[ ! -d /systems/homes/cronjobs_bk/mysql11 ]]
+ [[ -z root ]]
+ [[ ! -z root ]]
+ crontab -l -u root

shift $((OPTIND-1))
+ shift 6

exit 0
+ exit 0
 
Old 06-23-2016, 01:42 PM   #42
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,258

Rep: Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947
Did you look at the debugging output at all? You really need to start learning how to debug this stuff yourself.

In this case, location is getting set, you can see it in your output:
Code:
+ location=/var/log
However if you look at the rest of the code, $location is never used. That variable is never referenced again after getting set.

Again, put echo statements in your program so you can see what's going on when it doesn't work correctly. This will be my last post in this thread, good luck.

Last edited by suicidaleggroll; 06-23-2016 at 01:47 PM.
 
1 members found this post helpful.
Old 06-23-2016, 02:15 PM   #43
linuxnewbie0101
Member
 
Registered: Dec 2015
Posts: 46

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by suicidaleggroll View Post
Did you look at the debugging output at all? You really need to start learning how to debug this stuff yourself.

In this case, location is getting set, you can see it in your output:
Code:
+ location=/var/log
However if you look at the rest of the code, $location is never used. That variable is never referenced again after getting set.

Again, put echo statements in your program so you can see what's going on when it doesn't work correctly. This will be my last post in this thread, good luck.

i thought

if [[ ! -z $location ]]; then
$bkuplocation=$location
else
$location=$bkuplocation
fi

sets $location=$bkuplocation if $location is not null.

sorry i am still new to whole linux env and scripting.

Last edited by linuxnewbie0101; 06-23-2016 at 02:17 PM.
 
Old 06-23-2016, 02:25 PM   #44
michaelk
Moderator
 
Registered: Aug 2002
Posts: 14,930

Rep: Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520
Code:
if [[ ! -z $location ]]; then
  bkuplocation=$location
fi
If $location is not blank then set it to bkuplocation otherwise use the default as defined. The else part will not work unless you add a bunch of ifs which is not required.

Last edited by michaelk; 06-23-2016 at 02:55 PM.
 
1 members found this post helpful.
Old 06-23-2016, 02:25 PM   #45
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,258

Rep: Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947
Quote:
Originally Posted by linuxnewbie0101 View Post
i thought

if [[ ! -z $location ]]; then
$bkuplocation=$location
else
$location=$bkuplocation
fi

sets $location=$bkuplocation if $location is not null.
It would set $bkuplocation to $location if $location was not null, but that is not what's in your script. This is what's in your script:
Code:
#if [[ -z $location ]]; then
#  location=$bkuplocation
#fi

Last edited by suicidaleggroll; 06-23-2016 at 02:27 PM.
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to verify Cronjobs smilemukul Linux - Newbie 1 03-10-2011 03:57 PM
[SOLVED] cronjobs in ubuntu dinakumar12 Linux - Server 7 04-02-2010 06:31 AM
CronJobs error archey Linux - Newbie 4 08-22-2009 06:16 PM
Using cronjobs to mysql dump and scp backup to another box daiver Linux - General 4 11-10-2006 08:37 AM
Problem with cronjobs..... freakin'me Linux - General 7 02-11-2006 04:08 PM


All times are GMT -5. The time now is 02:09 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration