By jj2593


2019-10-14 22:07:58 8 Comments

I have multiple C programs I'm trying to run from my bash script. I know how to run the programs from the script but one of the programs takes arguments that are the output from another program. I need to run a program "dimensions" to find the dimensions of an image. Then I need to use those dimensions to crop an image into 4 quadrants.

What I have is below:

imageDirect=$1
imageOutput=$2

for file in "$imageDirect"/*; do
  "./dimensions" "$file" "-v"
  imageWidth=?
  imageHeight=?

  cropWidth=imageWidth/2
  cropHeight=imageHeight/2

  #what lower left quadrant crop call would be
  "./crop" "$file" "$imageOutput" "0" "0" "$cropWidth" "$cropHeight"

done

The output of dimensions will look like 256 256 where the first number is the width and second is the height. The line with ./crop is just to give an idea of what I'm doing.

The only thing I'm not sure of is how to get the output from dimensions and store both numbers in separate variables in my script.

0 comments

Related Questions

Sponsored Content

14 Answered Questions

[SOLVED] How do I set a variable to the output of a command in Bash?

64 Answered Questions

[SOLVED] Get the source directory of a Bash script from within the script itself

  • 2008-09-12 20:39:56
  • Jiaaro
  • 1573089 View
  • 4650 Score
  • 64 Answer
  • Tags:   bash directory

35 Answered Questions

[SOLVED] How to check if a program exists from a Bash script?

  • 2009-02-26 21:52:49
  • gregh
  • 614057 View
  • 2025 Score
  • 35 Answer
  • Tags:   bash

16 Answered Questions

[SOLVED] How to use SSH to run a shell script on a remote machine?

24 Answered Questions

[SOLVED] Pipe to/from the clipboard in Bash script

5 Answered Questions

9 Answered Questions

[SOLVED] How to get a password from a shell script without echoing

  • 2010-10-20 17:33:28
  • BD at Rivenhill
  • 315567 View
  • 382 Score
  • 9 Answer
  • Tags:   bash shell scripting sh

7 Answered Questions

[SOLVED] How to suppress all output from a command using Bash?

7 Answered Questions

[SOLVED] How does "cat << EOF" work in bash?

Sponsored Content