Powered by Invision Power Board


  Reply to this topicStart new topicStart Poll

> Basic UNIX script problem, some help would be great
Alsa
Posted: Apr 21 2005, 07:00 PM
Quote Post


Newbie
*

Group: Members
Posts: 1
Member No.: 940
Joined: 21-April 05



Hi guys and gals.

Could someone offer a little help to this annoying UNIX problem please? Ok, I gotta make a little script that jumps to a directory held in the environmental variables i.e


$ ./alsascript mypics

would take me to $HOME/pics kinda thing. so i made this code:

#!/bin/bash
set -a
_webspace=$HOME/public_html/
_powerpoint=$HOME/public_html/pp
_databases=$HOME/public_html/
_spreadheets=$HOME/public_html/
set +a

if [ -z "$1" ];
then echo argument is blank
else
eval cd $"$1" <<<<<<<<< ARGH!
echo New working directory is:
pwd

Now, when i run it from BASH and put say... ./alsascript powerpoint it says "powerpoint" is not a directory. But if i change that line where i put ARGH! to eval cd $_powerpoint or any of the other variables it works so i assume the syntax on that line is wrong but i can't find anywhere what it should be. Any ideas to make it work remembering that it must be BASH only. Its probably so obvious but I'm pretty new to unix, thank you in advance!
PMEmail Poster
Top
andyb1ack
Posted: Apr 26 2005, 03:33 PM
Quote Post


User Level: 4
****

Group: Members
Posts: 98
Member No.: 513
Joined: 9-September 04



You've made this a bit complicated I think.

You could use aliases.
If you execute the following command:
alias spreadsheets='cd $HOME/public.html?#39;
then you'd only have to type spreadsheets to be dropped into that directory.

I don't know what script is run automatically when you log in with the bash shell (it's the .profile for the korn shell), but you could put these aliases into that file, along with your PATH settings etc.

You can also put the following command into the file to display your "pwd" output on the command line (along with a blank line, hostname, and your logon:


PS1='
'`hostname`':${PWD}
'`whoami`' > '
export PS1


PMEmail Poster
Top
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:
« Next Oldest | Shells & Scripting | Next Newest »

Topic Options Reply to this topicStart new topicStart Poll

 



[ Script Execution time: 0.1995 ]   [ 12 queries used ]   [ GZIP Enabled ]




Partners: Cambridge Plus :: <Link Available> :: Illuminated Touch Panel :: <Link Available>
Unix Man Pages / Linux Man Pages :: HiFi Forum :: SIP VoIP Phone & Provider Reviews :: UNIX/Linux Forum Archives

More info on advertising on Unix/Linux Forum