Terminal troubles

Need help with C, C++, perl, python, etc?

Terminal troubles

Postby Deg » 2007-03-09 14:07

Hi,

I've got some problems using the terminal/console, I'm not sure what the official term is. A couple of weeks ago i decided to give debian a try and so far it's going really nice, a real eye opener. I decided to do my exercises from the accelerated c++ book in debian as well to slowly learn both at the same time. So far i came across two things that i can't figure out so i hope somebody here can help me.

1) After a lot of trial and error i figured out that executables can only be triggered in a directory outside the path by referring to them by they're full name or by using ./executable. Having used dos/windows for a long time this feels very strange for me. Is there a way to add the current directory to the path? I guess it's a no go because the path is probably not dynamic but i figured I'll ask.

2) I have to write programs that need a lot of input. In windows i would just make a textfile and then feed it to the executable, something like 'executable < textfile' I have been trying to do the same thing but so far i haven't got it to work. I tried to use the pipe since that's used with the more and less programs for example but textfile | less won't work since the textfile is not an executable. Is there a way to do this 'executable < textfile' in debian?

with regards,
Deg
Deg
 
Posts: 2
Joined: 2007-03-09 13:45

Re: Terminal troubles

Postby rbochan » 2007-03-09 14:25

Deg wrote:...Is there a way to add the current directory to the path? I guess it's a no go because the path is probably not dynamic but i figured I'll ask.

Check your user's .bash_profile file, you should be able to add to your path there. Log out for permanent changes to take effect.

2) I have to write programs that need a lot of input. In windows i would just make a textfile and then feed it to the executable, something like 'executable < textfile' I have been trying to do the same thing but so far i haven't got it to work. I tried to use the pipe since that's used with the more and less programs for example but textfile | less won't work since the textfile is not an executable. Is there a way to do this 'executable < textfile' in debian?

Interesting, because that does work in many situations. There are others more versed in bash than I am, perhaps they can be of some assistance.
...Rob

The American Dream isn't an SUV and a house in the suburbs;
it's Don't Tread On Me.
User avatar
rbochan
 
Posts: 267
Joined: 2006-09-21 19:46
Location: Central New York

Postby Grifter » 2007-03-09 15:18

command < input works, but if it's not pathed then you'd have to do ./command < input

example: less < textfile

pipe just pipes the output from the first to the second

example: cat textfile | grep pattern

similarly > redirects output, and < redirects input

you could copy the program into one of the pathed dirs, /bin /sbin /usr/bin /usr/sbin /usr/local/bin /usr/local/sbin, or make a bin dir in your home, and add this to your .bash_profile:

# set PATH so it includes user's private bin if it exists
if [ -d ~/bin ] ; then
PATH=~/bin:"${PATH}"
fi

it's possible this already exists in that file, but commented out, if so uncomment it
Eagles may soar, but weasels don't get sucked into jet engines...
Grifter
 
Posts: 1572
Joined: 2006-05-04 07:53
Location: Svea Rike

Postby Deg » 2007-03-12 20:23

Thanks for the help, i'm compiling to my bin dir now and it all works!
Deg
 
Posts: 2
Joined: 2007-03-09 13:45


Return to Programming

Who is online

Users browsing this forum: No registered users and 6 guests

fashionable