LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 09-13-2011, 11:51 PM   #1
sinoob
LQ Newbie
 
Registered: Feb 2004
Posts: 6

Rep: Reputation: 0
Passing string as a single argument in shell script


hi,

i have a shell script as follows, which takes two arguments.

###################################
FILE=$1
FOLDER=$2
APPUSER=jboss

#do something...

mypython.py 'sh myscript.sh /home/abcd/$FOLDER/$FILE'

###################################


what i want is, mypython.py (see the line above) should get the remaining portion as a single argument. As i am giving 'sh myscript.sh /home/abcd/$FOLDER/$FILE' within singlequotes, the $FOLDER and $FILE is not taking the original value.
If i am removing the single quote, then, 'sh' is taken as first argument, 'myscript.sh' is taken as second argument, and so on...
 
Old 09-14-2011, 01:32 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

In general single quotes stops bash from expanding variables. Have you tried double quotes? Those allow variable expanding.

Code:
mypython.py "sh myscript.sh /home/abcd/$FOLDER/$FILE"
Hope this helps.
 
1 members found this post helpful.
Old 09-14-2011, 03:10 AM   #3
sinoob
LQ Newbie
 
Registered: Feb 2004
Posts: 6

Original Poster
Rep: Reputation: 0
giving double quotes helped..
Thank you druuna !
 
Old 09-14-2011, 03:21 AM   #4
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
You're welcome
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] (Something like...) passing an argument to a MATLAB script Mike_V Programming 1 12-21-2009 04:04 PM
[SOLVED] Pass space (or string escaped) as argument to shell script. scmbg Programming 1 10-07-2009 10:15 AM
shell script, Passing string as argument? antis Programming 4 09-07-2007 01:03 AM
Bash script - passing command as string lenzj Programming 3 08-24-2006 11:36 AM
PHP Script argument passing error... lokee Linux - Software 5 04-24-2003 09:42 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 08:53 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration