# What's the FreeBSD equivalent of Linux "." (shell command)?



## mrjayviper (Apr 12, 2014)

In Linux, if I run a command 
	
	



```
my-prompt-here>. my-command-here
```
 I believe the command or script is run in a different shell session or something like that.

Is there a FreeBSD equivalent? I tried the example command I gave above but obviously using real scripts/command but it doesn't work.

Thanks


----------



## oliver@ (Apr 12, 2014)

*Re: What's the FreeBSD equivalent of Linux "." (shell comman*

"." is bourne shell syntax and leads to an execution in the *same* shell.
It is likley that on FreeBSD you're running a C-Shell where "source" would be the 'translation' of bourne-shells ".".
But you can also start a bourne shell on FreeBSD of course by just entering "sh" on the command line.
But I wonder why "." is important to you anyway? You don't usually need this outside shell-script programming.


----------



## mrjayviper (Apr 12, 2014)

*Re: What's the FreeBSD equivalent of Linux "." (shell comman*

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


----------



## ralphbsz (Apr 12, 2014)

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



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.


----------



## wblock@ (Apr 12, 2014)

*Re: What's the FreeBSD equivalent of Linux "." (shell comman*

sysutils/tmux is the newer alternative to sysutils/screen.


----------



## scottro (Apr 12, 2014)

*Re: What's the FreeBSD equivalent of Linux "." (shell comman*

While there are better tutorials, might as well link to my own.  At least one person at work found it useful. 

http://home.roadrunner.com/~computertai ... ntmux.html

It covers both, but as @wblock says, sysutils/tmux is newer


----------



## kpa (Apr 12, 2014)

*Re: What's the FreeBSD equivalent of Linux "." (shell comman*



			
				scottro said:
			
		

> While there are better tutorials, might as well link to my own.  At least one person at work found it useful.
> 
> http://home.roadrunner.com/~computertai ... ntmux.html
> 
> It covers both, but as @wblock says, sysutils/tmux is newer



It also has a distinct advantage over sysutils/screen, it's designed in such a way that the main binary does not have to be setuid root unlike in sysutils/screen.


----------



## mrjayviper (Apr 13, 2014)

*Re: What's the FreeBSD equivalent of Linux "." (shell comman*

Thanks everyone for the suggestions. I'll definitely look into screen/tmux.


----------



## ondra_knezour (Apr 13, 2014)

*Re: What's the FreeBSD equivalent of Linux "." (shell comman*

Coming late to the table, but have something special to test 

Ctrl+Z suspends running job and `bg` starts suspended job in background. See tcsh(1) manpage, the Jobs section.


----------

