Skip to main content
edited body
Source Link
Jeff Schaller
  • 68.8k
  • 35
  • 122
  • 265

I want to automate an installation and iI need to run the downloaded installer with gksu. I have tried:

attempt=0
  until
  gksu command; do
    attempt=$((attempt + 1))
    if [ "$attempt" -gt 3 ]; then
      exit 1
    fi
  done

but it doesn't exit until it reaches the third attempt. It doesn't matter if gksu has exited with exit code 0 or with a non zero exit code. What iI would like to be happen is:
while gksu command's exit code is not 0 and attempt number is not 3 repeat gksu command. If exit code is not 0 but attempt number is 3, exit the whole script. If exit code is 0 leave cycle and continue processing the script.
How could iI do that?

I want to automate an installation and i need to run the downloaded installer with gksu. I have tried:

attempt=0
  until
  gksu command; do
    attempt=$((attempt + 1))
    if [ "$attempt" -gt 3 ]; then
      exit 1
    fi
  done

but it doesn't exit until it reaches the third attempt. It doesn't matter if gksu has exited with exit code 0 or with a non zero exit code. What i would like to be happen is:
while gksu command's exit code is not 0 and attempt number is not 3 repeat gksu command. If exit code is not 0 but attempt number is 3, exit the whole script. If exit code is 0 leave cycle and continue processing the script.
How could i do that?

I want to automate an installation and I need to run the downloaded installer with gksu. I have tried:

attempt=0
  until
  gksu command; do
    attempt=$((attempt + 1))
    if [ "$attempt" -gt 3 ]; then
      exit 1
    fi
  done

but it doesn't exit until it reaches the third attempt. It doesn't matter if gksu has exited with exit code 0 or with a non zero exit code. What I would like to be happen is:
while gksu command's exit code is not 0 and attempt number is not 3 repeat gksu command. If exit code is not 0 but attempt number is 3, exit the whole script. If exit code is 0 leave cycle and continue processing the script.
How could I do that?

Source Link

How to repeat a command n times then exit?

I want to automate an installation and i need to run the downloaded installer with gksu. I have tried:

attempt=0
  until
  gksu command; do
    attempt=$((attempt + 1))
    if [ "$attempt" -gt 3 ]; then
      exit 1
    fi
  done

but it doesn't exit until it reaches the third attempt. It doesn't matter if gksu has exited with exit code 0 or with a non zero exit code. What i would like to be happen is:
while gksu command's exit code is not 0 and attempt number is not 3 repeat gksu command. If exit code is not 0 but attempt number is 3, exit the whole script. If exit code is 0 leave cycle and continue processing the script.
How could i do that?