Unable to change path in a bash script
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Shell > Unable to change path in a bash script




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Unable to change path in a bash script  
wizard


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
11-18-07 12:45 PM

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.





[ Post a follow-up to this message ]



    Re: Unable to change path in a bash script  
mallin.shetland


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
11-18-07 12:45 PM

wizard scrisse:

> ...
> It gives me the following error:-
> cd: /tmp;: No such file or directory
> ...

Try:

cd /tmp ;






[ Post a follow-up to this message ]



    Re: Unable to change path in a bash script  
wizard


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
11-18-07 12:45 PM

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.





[ Post a follow-up to this message ]



    Re: Unable to change path in a bash script  
Janis Papanagnou


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
11-18-07 06: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.





[ Post a follow-up to this message ]



    Re: Unable to change path in a bash script  
mallin.shetland


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
11-18-07 06: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








[ Post a follow-up to this message ]



    Re: Unable to change path in a bash script  
Joachim Schmitz


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
11-18-07 06: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







[ Post a follow-up to this message ]



    Re: Unable to change path in a bash script  
Janis Papanagnou


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
11-18-07 06: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
>
>





[ Post a follow-up to this message ]



    Re: Unable to change path in a bash script  
Maxwell Lol


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
11-19-07 12:33 PM

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 .

?





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 08:09 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register