Results 1 to 2 of 2
I am having a very strange scripting problem. I'm hoping that someone can help.
I am having a problem with a script running on a QNAP NAS device. It is ...
- 08-28-2009 #1Just Joined!
- Join Date
- Nov 2008
- Posts
- 9
[HELP] Very strange script problem
I am having a very strange scripting problem. I'm hoping that someone can help.
I am having a problem with a script running on a QNAP NAS device. It is running Linux version 2.6.24 (root NasX86-3) (gcc version 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)) #1 SMP Sat Jun 27 01:00:45 CST 2009. Bash version is GNU bash, version 3.2.0(1)-release-(i686-pc-linux-gnu).
Create the following test file as test.conf:
Please note there are five spaces between abc and def. At the command prompt type the following:Code:[Test] line1 = abc def
As you can see the returned value is correct. Now create the following script and name it test:Code:[~] # /sbin/getcfg Test line1 -f test.conf abc def [~] #
Now execute the script. The output should look correct.Code:#!#!/bin/sh /sbin/getcfg Test line1 -f ./test.conf
Now modify the script so it looks like this:Code:[~] # ./test abc def [~] #
Now execute it.Code:#!/bin/sh xxx=`/sbin/getcfg Test line1 -f ./test.conf` echo $xxx
Notice that the output is wrong. The five spaces between the abc and def have been reduced to one space. Why is assigning the output to a variable changing the output? What has happened and how do I prevent this from happening? This is really screwing up some code I have and I need a solution.Code:[~] # ./test abc def [~] #
Edit1:
If I execute the command directly from the command line it works. It only messes up when run from a script.
Code:[~] # xxx="`/sbin/getcfg Test line1 -f ./test.conf`" [~] # set . . xxx='abc def'
Thanks
Don
- 09-01-2009 #2Just Joined!
- Join Date
- Nov 2008
- Posts
- 9
Anyone have any ideas??


Reply With Quote