Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 741577
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T08:38:54+00:00 2026-05-14T08:38:54+00:00

I have this script that I am currently running that works great for all

  • 0

I have this script that I am currently running that works great for all instances but one:

 #!/bin/sh
 pdfopt test.pdf test.opt.pdf &>/dev/null
 pdf2swf test.opt.pdf test.swf
 [ "$?" -ne 0 ] && exit 2

More lines to execute follow the above code …

How would I go about changing this script to run “pdf2swf test.pdf test.swf” if “pdf2swf test.opt.pdf test.swf” fails? If the second attempt fails, then I would “exit 2“.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T08:38:55+00:00Added an answer on May 14, 2026 at 8:38 am

    Try:

    /path/to/pdfopt test.pdf test.opt.pdf >/dev/null && {
    
        pdf2swf test.opt.pdf test.swf
        ... maybe do more stuff here, in the future ...
        exit_here_nicely
    } 
    
    code_that_is_reached_if_pdfopt_failed
    

    In your example:

    pdfopt test.pdf test.opt.pdf &>/dev/null
    

    … pdfopt runs in the background, you have no idea how long it may take to complete. Let it block, so the code in the parens is reached only if it worked.

    A function wrapping that could easily launch in the background, but each process blocks until the first command exits as expected.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an SQL script (currently running against SQLite, but it should probably work
We have a Perl program that ran well on all Windows platforms so far.
Possible Duplicate: How may I reference the script tag that loaded the currently-executing script?
I have a program that uses the GPU for performing certain computations. I can
I am currently using Net::HTTP in a Ruby script to post files to a
I'm currently running a Django project on my school's webserver with FCGI. I did
I'm writing a simple dual timer in Python. (I'm running Linux, and this should
I have a problem with a function that doesn't work as expected since I
I'm currently using SWFUpload to upload files to my S3 bucket. And it's working
I'll try my best to explain how I'm trying to set up this system.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.