Re: What's the FreeBSD equivalent of Linux "." (shell comman
oliver@ said:
But I wonder why "." is important to you anyway? You don't usually need this outside shell-script programming.
I know two uses of it. The first one is sensible: Running setup scripts (similar to .profile, .cshrc and so on) that can't be done automatically at login. They can't be executed like normal commands (put "#!/bin/sh" into the first line and make them executable), because they mostly consist of commands that set variables. And they can't be done automatically, because there are external factors that determine which setup script to run.
The other use is a bit of a hack: quickly hack up a script that needs to be inspected before being run, but will be thrown away right afterwards. Sometimes I use pipes of find, awk, and such to create a script, put it in /tmp/foo, and then quickly check that I got it right. If yes, I can just say ". /tmp/foo". If I wanted to actually execute /tmp/foo the right way, I would have to add the hash-bang first line to it, and chmod it to be executable, and that's too much work.
But I agree: There are few uses of "." and "source".
mrjayviper said:
I want to:
1. ssh to my FreeBSD box and download the FreeBSD 10 from there
2. once I start downloading, I want to close my ssh session and turn off my macbook expecting once I wake up, my FreeBSD box would've downloaded the ISO for me.
Is this possible? thanks
How to you download FreeBSD 10? There are many ways to do it, ranging from command-line based (ftp or wget), all the way to using a web browser.
Simplest example: let's assume that you have a single shell command that does the job for you. I'll jokingly call it "download FreeBSD10". Then all you need to do: Put an ampersand "&" after the command, and it will run in the background. You probably want to also save the output (log, error messages from the command) somewhere, so you can come back later and see whether there were any problems. In that case, here is the whole command:
download FreeBSD10 > /tmp/download.log 2>&1 &
Not so simple example: You are using a command-line based tool, like ftp, that needs multiple subcommands. In that case, you need to keep your shell session running on a pseudo-terminal, while your macbook is off. The best solution is to run the
screen program on your FreeBSD machine. That creates a pseudo-terminal, from which you can run commands. Coming from the outside (with ssh), you can start a new pseudo-terminal, or re-attach to an existing one. This is a little too much to explain in a few sentences, so you should read the man page.