Sponsored Content
Full Discussion: Bash Calculator issue
Top Forums Shell Programming and Scripting Bash Calculator issue Post 302336231 by jsells20 on Tuesday 21st of July 2009 03:17:41 PM
Old 07-21-2009
Bash Calculator issue

Hello, I'm relatively new to using bc so I could use some help. In this script im working on I want to have the bc function to calculate float numbers for imagemagicks convert charcoal. Below is what I'm talking about. There are no syntax errors but when it outputs the users frames for example 0-10 the filter remains at an integer value. I want the filter to integrate with bc. I appreciate all help I can get. Thank you.

Code:
    count=$START
    SETSTEPS=$ (echo "scale=1; 1/25" | bc)

    SETTING=$SETSTEPS
    echo $SETSTEPS

        while [ $count -le $END ]; 
        do
        #echo $count

    #set for padding of 4 from 0-999.

        if [ $count -lt 10 ]; then 
        convert ${IMGDIR}${IMG} -charcoal $count ${OUTDIR}${OUT}.000$count.jpg
        fi

        if [ $count -ge 10 ] && [ $count -le 99 ]; then
        convert ${IMGDIR}${IMG} -charcoal $count ${OUTDIR}${OUT}.00$count.jpg
        fi
        
        if [ $count -ge 100 ] ; then
        convert ${IMGDIR}${IMG} -charcoal $count ${OUTDIR}${OUT}.0$count.jpg
        fi


        SETTING=$(echo "scale=4; $SETTING+$SETSTEPS" | bc)
        echo "processing frame: $count"

        let count=count+1

        # to view in maya's fcheck plugin
        #fcheck -n $START $END 1 ${OUTDIR}${OUT}.@@.jpg
        done

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

bash version or string issue

Hi all, I'm not sure but I guess, that is a bash version issue. The script working fine on "GNU bash, version 3.2.25(1)-release Ubuntu". #!/bin/bash while IFS=">" read a id val do if ] then VAL=${id%<*}; ID=${id#*</} echo $VAL echo $ID sed... (5 Replies)
Discussion started by: research3
5 Replies

2. Shell Programming and Scripting

bash integer & string issue

Hi guys, I need for the bash code below a little bit help: cat script.sh #!/bin/bash 5_MYVALUE="test" echo "$5_MYVALUE" If I try to run the script, got follow failure: ./script.sh ./script.sh: line 4: 5_MYVALUE=test: command not found _MYVALUE My questions are how... (4 Replies)
Discussion started by: research3
4 Replies

3. Shell Programming and Scripting

bash in perl issue

I use the following shell script in bash and it works fine. It returns 1 # cat /etc/httpd/conf/res.txt maldet(24444): {scan} scan completed on eicar_com.zip: files 1, malware hits 1, cleaned hits 0 # if ]; then echo 0 > /etc/httpd/conf/malflag; else echo 1 > /etc/httpd/conf/malflag;... (2 Replies)
Discussion started by: anilcliff
2 Replies

4. Shell Programming and Scripting

variable issue in a bash in a shell script

Hi, I am trying to write a PBS shell script that launches a bash process. The issue is that the bash process needs a variable in it and the shell script is interpreting the variable. How do I pass this as a literal string? Here is my code snippit: TMP=".fasta" FILEOUT=$FILE$TMP cd... (2 Replies)
Discussion started by: bioBob
2 Replies

5. Shell Programming and Scripting

syntax issue mysql in bash script

I'm running mysql in a bash script mysql <<EOF query EOF one query is like this: UPDATE $dbname.$prefix"config" SET value = $var WHERE "$prefix"config.name = 'table colname'; with variable but it's giving an error i'm not sure what to put for "$prefix"config.name the table... (3 Replies)
Discussion started by: vanessafan99
3 Replies

6. Shell Programming and Scripting

bash ls command file issue

ls -l /md01/EL/MarketData/inbound/ststr/INVENTORY* |tail -5 |awk '{ print $5,$6,$7,$8,$9 }'If I run the above from the command line the output to md_email is formatted correctly as 78213497 May 1 12:50 /md01/EL/MarketData/inbound/ststr/INVENTORY.20120430.PINESTREET.CSV.done 77904740 May 2... (3 Replies)
Discussion started by: smenago
3 Replies

7. Shell Programming and Scripting

Bash script and remote server issue

Hello, I'm attempting to run a script on a remote server via SSH but am having issues getting the script to run using proprietary binaries located on the remote server as it keeps complaining that commands are invalid on the local machine. If I run the script locally on the remote server, it... (2 Replies)
Discussion started by: shadyuk
2 Replies

8. Shell Programming and Scripting

Array Issue In Bash

Hi, I have the following code which is giving error mentioned below. Please can you support on this. Also suggest how can we access all the items against single vasservicename in circlename array,i.e, vasservicename say MTSTV will be available to all circles which are mentioned in the array... (2 Replies)
Discussion started by: siramitsharma
2 Replies

9. Shell Programming and Scripting

Bash arithmetic issue

I found the following issue by simply increasing a variable. The ((A++)) expression returns an error, the other expressions both return 0. Does anyone know why? script.sh: #! /bin/bash A=0 B=0 C=0 ((A++)) ; echo "${?}" ((B=B+1)) ; echo "${?}" ((C+=1))... (8 Replies)
Discussion started by: elbrand
8 Replies

10. UNIX for Beginners Questions & Answers

Compare bash arrays issue

Hello everyone, I need help comparing 2 arrays. the first array is static; the second array is not .. array1=( "macOS Mojave" "iTunes" ) cd /Volumes array2=( * ) # output of array2 macOS Mojave iTunes Mac me The problem occurs when I compare the arrays with the following code - ... (6 Replies)
Discussion started by: trexthurman
6 Replies
_lwp_sema_wait(2)						   System Calls 						 _lwp_sema_wait(2)

NAME
_lwp_sema_wait, _lwp_sema_trywait, _lwp_sema_init, _lwp_sema_post - semaphore operations SYNOPSIS
#include <sys/lwp.h> int _lwp_sema_wait(lwp_sema_t *sema); int _lwp_sema_trywait(lwp_sema_t *sema); int _lwp_sema_init(lwp_sema_t *sema, int count); int _lwp_sema_post(lwp_sema_t *sema); DESCRIPTION
Conceptually, a semaphore is an non-negative integer count that is atomically incremented and decremented. Typically this represents the number of resources available. The _lwp_sema_init() function initializes the count, _lwp_sema_post() atomically increments the count, and _lwp_sema_wait() waits for the count to become greater than 0 and then atomically decrements it. LWP semaphores must be initialized before use. The _lwp_sema_init() function initializes the count associated with the LWP semaphore pointed to by sema to count. The _lwp_sema_wait() function blocks the calling LWP until the semaphore count becomes greater than 0 and then atomically decrements it. The _lwp_sema_trywait() function atomically decrements the count if it is greater than zero. Otherwise it returns an error. The _lwp_sema_post() function atomically increments the semaphore count. If there are any LWPs blocked on the semaphore, one is unblocked. RETURN VALUES
Upon successful completion, 0 is returned. A non-zero value indicates an error. ERRORS
The _lwp_sema_init(), _lwp_sema_trywait(), _lwp_sema_wait(), and _lwp_sema_post() functions will fail if: EINVAL The sema argument points to an invalid semaphore. EFAULT The sema argument points to an illegal address. The _lwp_sema_wait() function will fail if: EINTR The function execution was interrupted by a signal or fork(2). The _lwp_sema_trywait() function will fail if: EBUSY The function was called on a semaphore with a zero count. The _lwp_sema_post() function will fail if: EOVERFLOW The value of the sema argument exceeds SEM_VALUE_MAX. SEE ALSO
fork(2) SunOS 5.11 8 May 1998 _lwp_sema_wait(2)
All times are GMT -4. The time now is 04:06 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy