Sponsored Content
Top Forums Shell Programming and Scripting Function works, trigger causes syntax error, whats my fault?? Post 302913260 by 1in10 on Thursday 14th of August 2014 09:23:50 PM
Old 08-14-2014
Function works, trigger causes syntax error, whats my fault??

Needing a hint. Creating that function called Meter my simple script works well. What I want now is to start the last four commented lines to include or trigger a reaction, if there are more than n lines in that .txt-file it shall display that message for example. But the interpreter says there is a syntax-error. Any hints? Thanks in advance!

Code:
#!/bin/bash
# name of the script is line3.sh
set -e
set -u
echo $0 

Meter ()
    {

Zet=$(wc -l /home/$USER/Desktop/14tilt.txt)
Ted=$(wc -c /home/$USER/Desktop/14tilt.txt)
    
}

Meter

echo "lines"    $Zet | cut -d '/' -f1 &&
echo "bytes"   $Ted | cut -d '/' -f1;

#if [ $Zet -gt 400 ]
# then echo "did it"
# else echo "not yet"
#fi;

exit 0;

But I am sure that this specific textfile contains more than 400 lines. So what can I do?

Last edited by 1in10; 08-14-2014 at 10:24 PM.. Reason: better reading
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Whats wrong with my function?? <newbie>

First of all im using Bash, on a Debian-based machine. I tried to write a function that if the ls program found listed more than 25 lines I would automaticly use "ls | less". Its on another computer but if I recall it looked something like this... Note: some code may look strange because im on... (4 Replies)
Discussion started by: riwa
4 Replies

2. Shell Programming and Scripting

Whats wrong with the syntax

Whats wrong with below logic or syntax???? (4 Replies)
Discussion started by: dsravan
4 Replies

3. Solaris

Whats the syntax for 'cut' in following?

Guys I am trying to get all physical plus logical interfaces on a host to pass them to a 'for' loop. 'ifconfig -a' gives me all interfaces like following...i need to cut last ':' from this list.What 'cut' syntax i need to use? bash-2.05$ ifconfig -a|awk '{print $1}'|sort|uniq|egrep -v... (13 Replies)
Discussion started by: ak835
13 Replies

4. Programming

segmentation fault while returning from function.

I am working on the application in which I have to fetch values from the database and paste in url and send it to portal. table=get_result("SELECT serialno,cas,Mode,FLC,TLC,location,CompName,CompCode,FG,FC,DispNo,TruckNo,LWbill,RRGPN,INVNO,DCN,RQTY,DQTY,SQTY,DDATE,RDATE,SDATE,TTIME FROM... (1 Reply)
Discussion started by: er.rohan88
1 Replies

5. Shell Programming and Scripting

Whats wrong in the Function ?

Need your assistance, to find the bug in the function. Function usage erroring out even after passing parameters. usage() { if || ; then echo "************************************************************" echo " CHECK USAGE FOR CORRECT PARAMETERS ... (26 Replies)
Discussion started by: raghunsi
26 Replies

6. Shell Programming and Scripting

whats the function of brackets here ?

Hello, as the title reads, in a control flow like "if" what's the function of brackets ? if condition then ... if ] then ... Since I saw people using them I wonder whether they are just inserts for code clearness or for the reliability ? thanks for your help Regards (9 Replies)
Discussion started by: Oddant
9 Replies

7. Shell Programming and Scripting

Syntax error piping to bc on command line - works when assigned to var

I have a script which outputs some timing data a line at a time. There are approx. 10 lines echoed, each line looks something like this: 0.741 http://checkip.dyndns.org 94.170.119.226Since I needed to add all the values in the first column, I piped the output to grep, matching and printing the... (7 Replies)
Discussion started by: gencon
7 Replies

8. Shell Programming and Scripting

Syntax Error while using CMP function

Hi All, I am getting a syntax error message while trying to compare 2 files using the compare function (LINUX) command substitution: line 79: syntax error near unexpected token `(' command substitution: line 79: `cmp -s <(tr , \n < $COMMON_TMP/nt_per_gs.done | sort) <(tr , \n <... (5 Replies)
Discussion started by: dsfreddie
5 Replies

9. Shell Programming and Scripting

Python - Function print vs return - whats wrong

All, I have a basic buzz program written in python with return function. If i change return with print,it works fine but i want to know whats wrong with return statement.Can anyone help me whats wrong with this #!/usr/bin/python def div4and6(s,e): for i in range(s,e+1): if... (5 Replies)
Discussion started by: oky
5 Replies

10. Shell Programming and Scripting

Bash function using variable in it syntax error

The below bash function uses multiple variables CODING, SAMPLE, SURVEY, andvariant in it. The user selects the cap function and details are displayed on the screen using the $SURVEY variable, the directory is changed to $SAMPLE and the samples.txt is opened so the user can select the sample to... (6 Replies)
Discussion started by: cmccabe
6 Replies
escape(1)							Mail Avenger 0.8.3							 escape(1)

NAME
escape - escape shell special characters in a string SYNOPSIS
escape string DESCRIPTION
escape prepends a "" character to all shell special characters in string, making it safe to compose a shell command with the result. EXAMPLES
The following is a contrived example showing how one can unintentionally end up executing the contents of a string: $ var='; echo gotcha!' $ eval echo hi $var hi gotcha! $ Using escape, one can avoid executing the contents of $var: $ eval echo hi `escape "$var"` hi ; echo gotcha! $ A less contrived example is passing arguments to Mail Avenger bodytest commands containing possibly unsafe environment variables. For example, you might write a hypothetical reject_bcc script to reject mail not explicitly addressed to the recipient: #!/bin/sh formail -x to -x cc -x resent-to -x resent-cc | fgrep "$1" > /dev/null && exit 0 echo "<$1>.. address does not accept blind carbon copies" exit 100 To invoke this script, passing it the recipient address as an argument, you would need to put the following in your Mail Avenger rcpt script: bodytest reject_bcc `escape "$RECIPIENT"` SEE ALSO
avenger(1), The Mail Avenger home page: <http://www.mailavenger.org/>. BUGS
escape is designed for the Bourne shell, which is what Mail Avenger scripts use. escape might or might not work with other shells. AUTHOR
David Mazieres Mail Avenger 0.8.3 2012-04-05 escape(1)
All times are GMT -4. The time now is 05:28 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy