Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Terminal troubles

Programming languages, Coding, Executables, Package Creation, and Scripting.
Post Reply
Message
Author
Deg
Posts: 2
Joined: 2007-03-09 13:45

Terminal troubles

#1 Post by Deg »

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

User avatar
rbochan
Posts: 266
Joined: 2006-09-21 19:46
Location: Central New York

Re: Terminal troubles

#2 Post by rbochan »

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.

Grifter
Posts: 1554
Joined: 2006-05-04 07:53
Location: Svea Rike

#3 Post by Grifter »

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...

Deg
Posts: 2
Joined: 2007-03-09 13:45

#4 Post by Deg »

Thanks for the help, i'm compiling to my bin dir now and it all works!

Post Reply