| Author |
Unable to change path in a bash script
|
|
| wizard 2007-11-18, 7:45 am |
| Hello friends,
I am trying to change path inside a bash script. What I am doing is
the following.
cd /tmp; find [A-Z] -type f -or -type l | grep wizkid
It gives me the following error:-
cd: /tmp;: No such file or directory
But when I execute the above command directly from shell, I get the
results. I dont know what is happening.
Kindly tell me where am I going wrong and oblige.
Thanks friends for visiting this thread.
Yours truly,
Wizard.
| |
| mallin.shetland 2007-11-18, 7:45 am |
| wizard scrisse:
> ...
> It gives me the following error:-
> cd: /tmp;: No such file or directory
> ...
Try:
cd /tmp ;
| |
| wizard 2007-11-18, 7:45 am |
| On Nov 18, 6:27 pm, "mallin.shetland" <mallin.shetl...@aol.com> wrote:
> wizard scrisse:
>
>
> Try:
>
> cd /tmp ;
It is already as
cd /tmp
It works fine on a command line if I do it, but fails inside the
script. I can't understand why.
Also, I tried the following command in a bash script:-
cmdOutput=`find /tmp -type f -or -type l | grep wizkid`
echo $cmdOutput
It gives me the following error:-
/usr/bin/find: paths must precede expression
Usage: /usr/bin/find [path...] [expression]
whereas, this runs fine on the command line.
| |
| Janis Papanagnou 2007-11-18, 1:28 pm |
| wizard wrote:
> Hello friends,
> I am trying to change path inside a bash script. What I am doing is
> the following.
>
> cd /tmp; find [A-Z] -type f -or -type l | grep wizkid
>
> It gives me the following error:-
> cd: /tmp;: No such file or directory
Is this a DOS file with CR (^M) before the line terminator FF?
If so get rid of that.
Janis
>
> But when I execute the above command directly from shell, I get the
> results. I dont know what is happening.
>
> Kindly tell me where am I going wrong and oblige.
>
> Thanks friends for visiting this thread.
>
> Yours truly,
> Wizard.
| |
| mallin.shetland 2007-11-18, 1:28 pm |
| wizard scrisse:
> ...
> It gives me the following error:-
>
> /usr/bin/find: paths must precede expression
> Usage: /usr/bin/find [path...] [expression]
>
> whereas, this runs fine on the command line.
Try running script whit xtrace on (eg: bash -x ./script
or #! /bin/bash -x) and doing some debug. You can put in
your script somethink as:
ls -l /
ls -l /tmp
pwd
| |
| Joachim Schmitz 2007-11-18, 1:28 pm |
| "Janis Papanagnou" <Janis_Papanagnou@hotmail.com> schrieb im Newsbeitrag
news:fhpipg$j4r$1@online.de...
> wizard wrote:
>
> Is this a DOS file with CR (^M) before the line terminator FF?
LF, not FF
Bye, Jojo
| |
| Janis Papanagnou 2007-11-18, 1:28 pm |
| Joachim Schmitz wrote:
> "Janis Papanagnou" <Janis_Papanagnou@hotmail.com> schrieb im Newsbeitrag
> news:fhpipg$j4r$1@online.de...
>
>
> LF, not FF
Sure. Typo. Thanks for catching it.
>
> Bye, Jojo
>
>
| |
| Maxwell Lol 2007-11-19, 7:33 am |
| wizard <vivek.j.joshi@gmail.com> writes:
> cd: /tmp;: No such file or directory
try
ls -ldg /tmp
and tell us what it says. It could be a symbolic link to a directory
that you don't have access to, or a remotely mounted file system.
And in a shell window, try
cd /tmp;df .
cd /; df .
That will tell you the disk partitions for "/" and "/tmp".
I want to see if they are different.
cd /;df .
?
|
|
|
|