Unable to change path in a bash script
Unable to change path in a bash script
am 18.11.2007 14:07:16 von vivek.j.joshi
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.
Re: Unable to change path in a bash script
am 18.11.2007 14:27:45 von mallin.shetland
wizard scrisse:
> ...
> It gives me the following error:-
> cd: /tmp;: No such file or directory
> ...
Try:
cd /tmp ;
Re: Unable to change path in a bash script
am 18.11.2007 14:39:56 von vivek.j.joshi
On Nov 18, 6:27 pm, "mallin.shetland" wrote:
> wizard scrisse:
>
> > ...
> > It gives me the following error:-
> > cd: /tmp;: No such file or directory
> > ...
>
> 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.
Re: Unable to change path in a bash script
am 18.11.2007 15:38:40 von Janis Papanagnou
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.
Re: Unable to change path in a bash script
am 18.11.2007 15:59:04 von mallin.shetland
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
Re: Unable to change path in a bash script
am 18.11.2007 16:10:13 von Joachim Schmitz
"Janis Papanagnou" schrieb im Newsbeitrag
news:fhpipg$j4r$1@online.de...
> 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?
LF, not FF
Bye, Jojo
Re: Unable to change path in a bash script
am 18.11.2007 19:28:08 von Janis Papanagnou
Joachim Schmitz wrote:
> "Janis Papanagnou" schrieb im Newsbeitrag
> news:fhpipg$j4r$1@online.de...
>
>>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?
>
> LF, not FF
Sure. Typo. Thanks for catching it.
>
> Bye, Jojo
>
>
Re: Unable to change path in a bash script
am 19.11.2007 12:38:38 von Maxwell Lol
wizard 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 .
?