Second parameter is not recognized


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Second parameter is not recognized
# 1  
Old 07-06-2011
Second parameter is not recognized

Hey I have a problem with my script.
I writing a script which can depend whether you want to make a file or a directory.
I only give the code where you can find the problem.
My loop doesn't stop and I don't know why and
when i echo my second parameter , he echoes nothing :s

Thnx

Code:
function files()
{
 local var=$2;
 for (( i=1;i -le $var;i++))               
 do
  touch test$i /home/arian/Bureaublad/scripts
  echo $i
done
}

case $1 in
  "-f")files $2;;
    *) echo "foutieve ingave ! optie + aantal bestanden/mappen";;
esac

# 2  
Old 07-06-2011
Inside your function, $n refer to the n-th passed argument to the function, and NOT to the n-th passed argument of the script

Your function has 1 argument so you want to refer to the passed argument :

Code:
local var=$1

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Passing parameter to script, and split the parameter

i am passing input parameter 'one_two' to the script , the script output should display the result as below one_1two one_2two one_3two if then echo " Usage : <$0> <DATABASE> " exit 0 else for DB in 1 2 3 do DBname=`$DATABASE | awk -F "_" '{print $1_${DB}_$2}` done fi (5 Replies)
Discussion started by: only4satish
5 Replies

2. Shell Programming and Scripting

Command that takes one parameter and then searches for the passed in parameter

Hi I am looking for a unix command or a small shell script which can takes one parameter and then searches for the passed in the parameter in any or all files under say /home/dev/ Can anyone please help me on this? (3 Replies)
Discussion started by: pankaj80
3 Replies

3. Shell Programming and Scripting

Alias not recognized within script

What would cause a script to work under one user account and not another? Here's an example of what I'm referring to. Here's a simple script. Let's put it in a file called “thescript”. #! /bin/bash alias a='echo hello world' a Here are the results when this script is executed logged in... (3 Replies)
Discussion started by: sszd
3 Replies

4. Shell Programming and Scripting

$1 argument not being recognized

I am working on AIX 6.1 issuing #!/bin/sh at the beginning of the script. I don't understand why $1 is not working as expected. I expect it to hold the value for the first argument coming from the command line consistently - and it is not. At the beginning of the script starting I do this:... (4 Replies)
Discussion started by: Feliz
4 Replies

5. Linux

PCI Card recognized

I installed PCI Card HP SC44Ge - SAS1068E on my linux CentOS 5.4 is there a way to find out if the PCI is properly installed and recognized by linux. lspci is enough? just to add that PCI card is connected to a tape... also how can I find out driver and firmware version? thanks a... (1 Reply)
Discussion started by: karlochacon
1 Replies

6. Solaris

New volume set not recognized

Good evening, I am fairly (re)new to Solaris 10. In fact I was even quite good at it, but that was about 10 years ago, so now I am back to beginner status :) I installed a new machine with an internal 16port RAID attached to an Areca 1260 controller. Also attached is an external SCSI-Raid. ... (7 Replies)
Discussion started by: PatrickBaer
7 Replies

7. UNIX for Dummies Questions & Answers

jar command not being recognized

Hi, I'm trying to extract a war file via the jar command; however, when I issue: jar -xvf MyWarFile.war I'm recieving "jar: not found" I added /usr/bin to the path ...didn't work also tried /usr/bin/jar to the path...still doesn't work My JAVA_HOME/bin is also in the path. ... (1 Reply)
Discussion started by: orahi001
1 Replies

8. Shell Programming and Scripting

how do I make dynamic parameter names? Or get the value of a parameter evaluated twi

Say I write something like the following: var1=1 var2=2 for int in 1 2 do echo "\$var$int" done I want the output to be: 1 2 Instead I get something like: $var1 $var2 (2 Replies)
Discussion started by: Awanka
2 Replies

9. Forum Support Area for Unregistered Users & Account Problems

I am not being recognized

Hi Admin, My user id is "chanakyahere", i forgot my password. When i give my mail id "chanakyahere@gmail.com" it is not being accepting by webmaster. But to the same mail id i got reply to one of my questions. The same mail id i gave while registering in this site. This i can confirm as... (0 Replies)
Discussion started by: Help
0 Replies

10. Shell Programming and Scripting

Argument not recognized as integer

I need to accept a number of arguments at command line and print it in reverse order i use eval `echo x=$1` to capture the argument #! /bin/sh counter=0 while do eval `echo x=$1` arg$counter=$x counter=`expr $counter + 1` shift done but the error keeps... (1 Reply)
Discussion started by: scmay
1 Replies
Login or Register to Ask a Question