Log in

View Full Version : BASH question



acolyte_to_jippity
10-19-2010, 11:29 AM
ok all you linux and unix experts!

i got a bit of a question for you.

in class, we're using alot of Unix stuff. we're using SSH Secure Shell client to connect to the school's unix machines (dunx1 and tux). I've changed my shell over from c-shell to BASH. after getting bored of the default BASH prompt, i changed it.

in order to do so, (and keep the change for each session) i created a file in myhome directory called .bash_profile and placed the following line in it:

PS1="(\#)[\h:\W]touch me$ "

what that does is it makes my prompt tell me the # of commands i've executed so far, the name of the machine i'm on, and the directory i'm in. it works beautifully.

here's where my problem appears. whenever i cd to a new directory, i always type "ls -lah" to list what's in it. to save time and because i was bored, i decided to make that into a shell function. now, my .bash_profile reads:


PS1="(\#)[\h:\W]touch me$ "
function cdsee(){ cd $1; ls -lah;}

however, my prompt is now being displayed AFTER everything i do. and the cursor is in front of it, so i end up typeing over my prompt. example:

(2)[dunx1:aea56]touch me$ _ <--normal, i'd start typing at the _

(7)[dunx1:aea56]touch me$ <---now, again, i type at the _ but this time it's on top of the prompt


there is no reason i can see that would cause this, so i'm hoping that one of you might have some sort of hidden technique up your sleeves that can help. thanks guys!

Fireye
10-19-2010, 12:08 PM
in order to do so, (and keep the change for each session) i created a file in myhome directory called .bash_history and placed the following line in it:

PS1="(\#)[\h:\W]touch me$ "


Did you mean, you created a file named .bash_profile? .bash_history isn't where that belongs.

Edit: Your stuff works fine for me, in ubuntu 10.10

acolyte_to_jippity
10-19-2010, 12:10 PM
Did you mean, you created a file named .bash_profile? .bash_history isn't where that belongs.

:facepalm:

yeah, that's what i meant. i had been looking at my .bash_history right before typing that post to see when it gets wiped (after each session or not)

changed that in my post. thanks.

acolyte_to_jippity
10-20-2010, 10:51 AM
Edit: Your stuff works fine for me, in ubuntu 10.10

i have no fucking clue what's going on with it. according to the accounts support people, they're not getting this thing either. and i'm not on ubuntu. it's a remote unix machine...but that shouldn't make a difference.

Fireye
10-20-2010, 10:56 AM
i have no fucking clue what's going on with it. according to the accounts support people, they're not getting this thing either. and i'm not on ubuntu. it's a remote unix machine...but that shouldn't make a difference.

"remote unix machine" really isn't specific enough. What flavor of Unix, Linux, or BSD is it running? What version of bash is it running (try bash --version).

You can use uname -a to find out what kernel it's running, and if it has lsb_release, you can try that too (lsb_release -a).

acolyte_to_jippity
10-20-2010, 12:18 PM
bash --version

GNU bash, version 2.05b.0(1)-release (sparc-sun-solaris2.9)
Copyright (C) 2002 Free Software Foundation, Inc.

uname -a

SunOS dunx1 5.9 Generic_118558-38 sun4u sparc SUNW,Sun-Fire

edit: i might have just fixed it. i needed a semicolon after the PS1= line in my .bash_profile

Fireye
10-20-2010, 12:23 PM
Oh, you're running on Solaris? Good luck, have fun, I'll waaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaay over here!

acolyte_to_jippity
10-20-2010, 12:33 PM
Oh, you're running on Solaris? Good luck, have fun, I'll waaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaay over here!

well, like i said. i fixed the prompt thing.

but now i think i broke the other machine...

tux no longer lets me onto the ftp server...FUCK

Fireye
10-20-2010, 12:38 PM
well, like i said. i fixed the prompt thing.

but now i think i broke the other machine...

tux no longer lets me onto the ftp server...FUCK

Are you able to get to the banner or user/pass prompt on it? If not, check netstat -ant (not sure how that translates to solaris) and see if anything is listening on port21.

acolyte_to_jippity
10-20-2010, 12:41 PM
Are you able to get to the banner or user/pass prompt on it? If not, check netstat -ant (not sure how that translates to solaris) and see if anything is listening on port21.

well, the other machine's one works fine (dunx1).

i can log onto tux using the ssh client, but the ftp won't connect when i open a session (i use Secure Shell ssh)

edit: netstant -ant gave me alot of stuff, but:

tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN



i'm pretty sure it's port 22 for me

edit edit: ahhhh, tux is not solaris.

bash --version:

GNU bash, version 3.2.48(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2007 Free Software Foundation, Inc.


uname -a:

Linux tux64-12.cs.drexel.edu 2.6.29-8-cs-np #9 SMP Sun Aug 16 00:46:06 EDT 2009 x86_64 GNU/Linux


lsb_release -a:

No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 9.04
Release: 9.04
Codename: jaunty

Fireye
10-20-2010, 12:45 PM
well, the other machine's one works fine (dunx1).

i can log onto tux using the ssh client, but the ftp won't connect when i open a session (i use Secure Shell ssh)

edit: netstant -ant gave me alot of stuff, but:

tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN



i'm pretty sure it's port 22 for me

...... ok, you're using SFTP. VERY important difference. One runs over ssh (port22), and FTP runs on port21. You could try running sftp -v <user@host>, which will give you verbose output, and let you know why it's not working.

acolyte_to_jippity
10-20-2010, 12:52 PM
...... ok, you're using SFTP. VERY important difference. One runs over ssh (port22), and FTP runs on port21. You could try running sftp -v <user@host>, which will give you verbose output, and let you know why it's not working.

ok, i edited my last post w/ some more info.

but i debugged it, and well...

i got to where it told me to enter password and i couldn't type my password in. i could type after i hit 'enter' but then of course it counted that as a blank pass and asked me for it again

anyway, i have to go. i'll talk to you later

-=NYS=- C.O.
10-26-2010, 04:55 PM
Good Job Nerds !! Keep up the good work !!! :wtg:

acolyte_to_jippity
10-26-2010, 05:33 PM
Good Job Nerds !! Keep up the good work !!! :wtg:

yah...it's still borked.

so i'm just going to get them to reset my account.

fml.

-=NYS=- C.O.
10-26-2010, 06:06 PM
yah...it's still borked.

so i'm just going to get them to reset my account.

fml.


I learned a new word.

www.urbandictionary.com/define.php?term=borked

acolyte_to_jippity
10-26-2010, 06:13 PM
I learned a new word.

www.urbandictionary.com/define.php?term=borked

it applies. even after i told the guy who runs the fucking thing exactly what i did, he couldn't reproduce the error. i believe the exact quote was "how in the fuck did you do that?"

-=NYS=- C.O.
10-26-2010, 06:21 PM
it applies. even after i told the guy who runs the fucking thing exactly what i did, he couldn't reproduce the error. i believe the exact quote was "how in the fuck did you do that?"

I'd pay to be there when he said that. :lmao:

maynard
10-26-2010, 08:08 PM
Good Job Nerds !! Keep up the good work !!! :wtg:

lol...

BladeTwinSwords
10-27-2010, 10:48 AM
Nerds make the world go round.

Of course gravity and money do that just as well.

-=NYS=- C.O.
10-27-2010, 10:58 AM
Nerds make the world go round.

Of course gravity and money do that just as well.

I agree. Japs are also needed for their crazy technological shit too.