Simple multiplication problem


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Simple multiplication problem
# 8  
Old 07-06-2007
Greekozz,
As I said in my explanation above, the shell will interpret metacharacters.
If you do not want it to happen before the data is sent to your script,
then:
1) Escape it.
2) 'set -f'
In this case, either one must be done in the unix prompt.
To escape it:
Code:
your_shell.sh 2 '*' 3
or
your_shell.sh 2 "*" 3

To 'set -f':
Code:
unix prompt>set -f

# 9  
Old 07-06-2007
Quote:
Originally Posted by Shell_Life
2) 'set -f'
In this case, either one must be done in the unix prompt.
To 'set -f':
Code:
unix prompt>set -f

Or you could do this in bash.

Within your script, look for the keyword 'noglob' in the env variable SHELLOPTS. If it is present, then it means set -f was done. Else do a set -f and then exec yourself again.

Something like
Code:
#! /bin/sh

opts=${SHELLOPTS}
if [[ $opts = *noglob* ]] ; then
  # run the script
else
  set -f
  exec $0 $*
fi;

Not tested tho'.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

simple wc problem

Hi there, Im sure there is a simple explanation for this but I have a file like this with no balnk lines peter paul john I run the command # var=`grep paul file.txt` # echo $var paul # echo $var | wc -l 1 but when I grep for a value that isnt in the file, i still... (4 Replies)
Discussion started by: rethink
4 Replies

2. Shell Programming and Scripting

another simple awk problem

Hello; I need to print two previous lines after searching for a reg exp: awk '/haywood/' should produce the following =================== p9J46THe020804 89922 Tue Oct 18 21:06 MAILER-DAEMON (host map: lookup (haywood.com): deferred) ... (1 Reply)
Discussion started by: delphys
1 Replies

3. Shell Programming and Scripting

simple awk problem

Hello; I have the following log file: 10/11/11 10:42:02 LOCK Q Userid:284 Username=root UserPID:23158 Device:marlin batch 10/11/11 10:42:02 TableNr:226 TableName:iatkn RecId:116290398 Flags:X Q H 10/11/11 10:42:02 LOCK CONTENTION X 10/11/11 10:42:02 ... (3 Replies)
Discussion started by: delphys
3 Replies

4. Shell Programming and Scripting

Please help me with a simple problem

Hi, I have a very simple script like below: for n in 10 20 30 do for a in 30 40 50 60 70 80 do for r in 2 3 4 5 6 7 do m=$((r*a)) count=1 while do echo "a = " $a ", m = " $m ", n = " $n ... (2 Replies)
Discussion started by: Dark2Bright
2 Replies

5. Programming

Simple g++ compilation problem

I'm trying to port some code over to unix Solaris. I'm not really a unix programmer so I'm sure this is something straight-forwards but I'm getting the following: > g++ -c CTrade.cpp In file included from CTrade.cpp:1: stdafx.h:6: warning: `#pragma once' is obsolete CTrade.cpp:4: iostream: No... (1 Reply)
Discussion started by: achartley
1 Replies

6. Shell Programming and Scripting

simple jsp problem.

I have my jsp page located at /install/apache-tomcat-5.5.29/webapps/jsp-examples/light/login.jsp There fore i will have to use following url to access it. localhost:8080/jsp-examples/light/login.jsp How would i make this little shorter like. localhost:8080/login.jsp I m using... (13 Replies)
Discussion started by: pinga123
13 Replies

7. Shell Programming and Scripting

simple awk problem

pcn linus> ntpq -p remote refid st t when poll reach delay offset disp ============================================================================== +smpnn01 ntpsrv1 2 u 829 1024 377 1.46 0.793 0.85 *smpnn02 ntpsrv1 2 u ... (2 Replies)
Discussion started by: arch12
2 Replies

8. Shell Programming and Scripting

Simple regex problem?

Hi all, I am looking to create words from a sentence which adhere to a custom search pattern from my website: Example: ! +! / += ~ where the terms ! = not, +! = AND NOT, += - and equals and ~ = can be like.... Now here is the issue...i want to split a sentence like the one above on... (1 Reply)
Discussion started by: muay_tb
1 Replies

9. Shell Programming and Scripting

Simple Scripting Problem

Hi there, I was trying to add a line of text in the middle line of a file. I have counted the lines in the file, and then I divide it into 2, after that I am stuck on how am I suppose to append the line on that file? When I tried to use this command 'second line >> filename' it appends it at... (3 Replies)
Discussion started by: felixwhoals
3 Replies

10. UNIX for Advanced & Expert Users

A simple Samba problem, please help

Hi, I have successfully setup my Samba server on my Sun Solaris 8 Sparc machine. My Win2000 workstation is able to see the unix worstation and its shared directory from Network Neighborhood. However, the Unix workstation appears as Ip address instead of Hostname on my network neighborhood... (5 Replies)
Discussion started by: champion
5 Replies
Login or Register to Ask a Question