Problem with parameters ( $1, $2... )


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Problem with parameters ( $1, $2... )
# 1  
Old 03-24-2010
Problem with parameters ( $1, $2... )

I have problem with params...I have created a script, which needs a path to PDF file as parameter.

for instance:

Code:
sh myScript.sh $HOME/myPdf.pdf

the problem is, when the PDF's name is not just myPDF.pdf but my pdf.pdf...I want to say, that the name of the PDF is separated by spaces, and my script takes it as more params not just one... $1 is my and $2 is PDF.pdf

How can I solve this problem when the name of the PDF or when the PATH part contains spaces, my script will take it as one parameter.

thanks for reply.

//Edit: I find the mistake! the problem is not in params, but in the tool which I use..

Last edited by Lukasito; 03-24-2010 at 05:23 PM..
# 2  
Old 03-24-2010
You need to do:
Code:
$ myScript.sh "my pdf.pdf"

That is surround filename with spaces in them with speech marks.

The sh is not necessary if myScripts.sh is executable, e.g. run:
Code:
$ chmod u+x myScripts.sh

to make it so.
# 3  
Old 03-25-2010
I've surrounded the $1 with "" and it works :P
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

Kernel parameters problem in Solaris 10

please tell me the list of kernel parameters in solaris10. Because we've a requirement in one project. Also tell me the importance of eah kernel parameter if possible. Thanks in Advance.:):cool: (2 Replies)
Discussion started by: vamshigvk475
2 Replies

2. Red Hat

Kernel parameters problem in Linux

please tell me the list of kernel parameters in RHEL 5.7 Because we've a requirement in one project. Also tell me the importance of eah kernel parameter if possible. ==Thanks in Advance==:):D (1 Reply)
Discussion started by: vamshigvk475
1 Replies

3. Programming

C++ problem displaying parameters using dOxygen

I have written some C++ code with documentation code for dOxygen as below. However the parameters are not showing up. /// \file /// /// #ifndef __VECT2_HH__ #define __VECT2_HH__ #include <iostream> #include <assert.h> #include <cmath> #include "common.hh" ... (0 Replies)
Discussion started by: kristinu
0 Replies

4. UNIX for Dummies Questions & Answers

Problem with command line parameters

hi, This is actually realted to a Abinitio command in a unix script. my code is #!/bin/ksh GRAPH_NAME=$1 shift air sandbox run $GRAPH_NAME $* > file.lst 2>&1 if ]; then echo "Pass" fi when i run this script with this command "script.ksh graph_name parameters" the script... (1 Reply)
Discussion started by: siva1612
1 Replies

5. Shell Programming and Scripting

Problem with input parameters

Hi I wrote a script which lists the content of a given directory. I have just one problem. If you give 2 or more parameters, then it gives a strange error. After that error, it gives also an error from my script, but normally it shouldn't give that error. Here's my script.You can test it. ... (3 Replies)
Discussion started by: hss
3 Replies

6. Shell Programming and Scripting

Problem with Input parameters

Hi, I am facing a weird problem with input parameters. Please find more details about my problem below: a) I am executing a korn shellscript with 11 input parameters from "Appworx" tool (it's a scheduling tool) and immediately displaying those 11 parameter values in unixscript and noticed... (4 Replies)
Discussion started by: npk2210
4 Replies

7. Shell Programming and Scripting

(Problem) Script with Parameters file

Hello, this is my first post, and.... obviusly, i have a problem, i have this script: #!/bin/sh . /tmp/variables ... ... DESTINATION=`hostname`_DESTINATION ... and the /tmp/variables has: #!/bin/sh aix53_DESTINATION="/temporal/`hostname`.mksysb.`date +\%d\%m\%y`" ** The problem is... (2 Replies)
Discussion started by: pelado
2 Replies

8. Shell Programming and Scripting

Problem with script not able to take parameters passed to it

debug output: (3 Replies)
Discussion started by: dsravan
3 Replies

9. Shell Programming and Scripting

Problem with script not able to take parameters passed to it

when I pass any 2 parameters it always says: Number of parameters passed: 1 and the job_name as x Can some body help? (7 Replies)
Discussion started by: dsravan
7 Replies

10. Shell Programming and Scripting

problem in passing parameters with spaces

hi im passing 4 parameters to a file....like /userr/script/go.sql $1 $2 $3 $4 and i get them in the other script and make and insert into the tabke insert into xy values('&1','&2','&3','&4'); what is the problem is tht when any one paramter has a space in them like "airtel... (2 Replies)
Discussion started by: njraman
2 Replies
Login or Register to Ask a Question