Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

BASH Unix Script problem

Name: Als 2005-04-21 7:35

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?  Thank you in advance!

Name: Anonymous 2005-04-21 16:00

bash-2.05b$ _a=aaaaa
bash-2.05b$ m=_a
bash-2.05b$ eval echo \$"${m}"
aaaaa

how do you expect this to work anyway? by making this an actual script and not some function inside your .bashrc, you effectively start a new shell, tell it to cd to some dir and exit. the parent shell remains in the same directory you were in prior to launching the script.
why don't you just alias the directories? eg.
alias ppt="cd $HOME/public_html/pp"
reduces typing time.

Name: Alsa 2005-04-21 16:08

Thanks, I'll give that a whirl.  I don't ever expect to use it, its for a rather dull assignment requested by our rather dull tutor to show we can make a Unix script which uses environmental variables.

Name: test<>faggot 2008-04-10 19:51

lol what

Name: test 2008-04-10 20:12

quoting bold
still bold?

Name: test 2008-04-10 20:25

quoting overline
still overline?

Name: test 2008-04-10 20:27

I'M
AN
EXPERT
BBCODE
PROGRAMMER

Name: test 2008-04-10 20:29

I'M[o]
AN[o]
[b][u][o][i]EXPERT
BBCODE
PROGRAMMER[/i][/u][/b]
[/o][/o][/o]

Name: test 2008-04-10 20:30

I'M
AN
EXPERT
BBCODE
PROGRAMMER

Name: test 2008-04-10 20:34

B
B
C
O
D
E

M

A

S

T

E

R

Name: test 2008-04-10 20:37

B
B
C
O
D
E

M
A
S
T
E
R

Name: test 2008-04-10 20:38

B
B
C
O
D
E
 
M
A
S
T
E
R

Name: test 2008-04-10 20:39

B
B
C
O
D
E

M
A
S
T
E
R

Name: test 2008-04-10 20:40

B
B
C
O
D
E
 
M
A
S
T
E
R

Name: Anonymous 2009-01-15 7:29

bish bash bosh

Name: Anonymous 2009-01-15 10:30

I
always
wanted
> to try
> > this

Name: Anonymous 2009-01-15 10:31

>>
>>
> > > > > >
> > >> > >>> > >> >> > > >> > >>>
halp

Name: IHBT 2009-01-15 15:54

>>1
eval cd $"$1"
eval cd '$'$1

Name: Anonymous 2009-01-15 18:47

hello im patrick the gingor join my community of haxxors if you payme enough i will give you access to a secret area of /YHBT/ ;)

Name: Anonymous 2010-11-28 10:05

Name: Anonymous 2011-01-31 20:05

<-- check em dubz

Name: Anonymous 2013-07-29 9:15

check em

Don't change these.
Name: Email:
Entire Thread Thread List