zsh-users
 help / color / mirror / code / Atom feed
* remote function problems.
@ 2000-01-11  4:49 Scott Lipcon
  2000-01-12  7:29 ` Andrej Borsenkow
  0 siblings, 1 reply; 6+ messages in thread
From: Scott Lipcon @ 2000-01-11  4:49 UTC (permalink / raw)
  To: zsh-users

Hello,

I'm trying to write some function to distribute my config files among all
the machines I use.  For various reasons, I dont want to use rsync or CVS.
I want to "push" the files out from my main machine, so I have a function
which tars them up and scp's them to the remote machine (prompting for a
password if necessary)

I also have a function which installs the config files properly, from a
tar file in my home directory.  The problem is now executing that function
remotely, via ssh.

The best I've come up with is:

$ ssh remote-host zsh -i -c function

which runs the function, but also outputs:

stty: standard input: Invalid argument

is there a way to do this better?  

Thanks,

Scott


^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: remote function problems.
  2000-01-11  4:49 remote function problems Scott Lipcon
@ 2000-01-12  7:29 ` Andrej Borsenkow
  2000-01-12 18:52   ` Scott Lipcon
  0 siblings, 1 reply; 6+ messages in thread
From: Andrej Borsenkow @ 2000-01-12  7:29 UTC (permalink / raw)
  To: Scott Lipcon, zsh-users

You most probably have call to stty in your .zshrc or /etc/zshrc (that is being
executed for every interactive shell; and you force your shell to be interactive
with -i option).

1. Do not use -i option. Why do you need it?

2. Wrap call to stty around

if [[ -t 0 ]]; then
	stty ...
fi

/andrej

> -----Original Message-----
> From: Scott Lipcon [mailto:slipcon@ugrad.cs.jhu.edu]
> Sent: Tuesday, January 11, 2000 7:49 AM
> To: zsh-users@sunsite.auc.dk
> Subject: remote function problems.
>
>
> Hello,
>
> I'm trying to write some function to distribute my config files among all
> the machines I use.  For various reasons, I dont want to use rsync or CVS.
> I want to "push" the files out from my main machine, so I have a function
> which tars them up and scp's them to the remote machine (prompting for a
> password if necessary)
>
> I also have a function which installs the config files properly, from a
> tar file in my home directory.  The problem is now executing that function
> remotely, via ssh.
>
> The best I've come up with is:
>
> $ ssh remote-host zsh -i -c function
>
> which runs the function, but also outputs:
>
> stty: standard input: Invalid argument
>
> is there a way to do this better?
>
> Thanks,
>
> Scott
>
>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: remote function problems.
  2000-01-12  7:29 ` Andrej Borsenkow
@ 2000-01-12 18:52   ` Scott Lipcon
  2000-01-12 19:20     ` Peter Stephenson
  0 siblings, 1 reply; 6+ messages in thread
From: Scott Lipcon @ 2000-01-12 18:52 UTC (permalink / raw)
  To: Andrej Borsenkow; +Cc: Scott Lipcon, zsh-users

On Wed, 12 Jan 2000, Andrej Borsenkow wrote:

> You most probably have call to stty in your .zshrc or /etc/zshrc (that is being
> executed for every interactive shell; and you force your shell to be interactive
> with -i option).

yes, I do have a stty erase call in my .zshrc  

> 1. Do not use -i option. Why do you need it?

if I don't specify -i, it doesn't find my functions... I get:

$ ssh hostname zsh -c function
slipcon's password:
zsh: command not found: function
$

this is because I load my functions in my .zshrc - they're all in a file
called zfunc, and I say:


# load functions (necessary for completions)
[[ -r $HOME/.zsh/zfunc ]] && source $HOME/.zsh/zfunc

in my zshrc.  (which is directly before I load in my completions, which
are in $HOME/.zsh/zcomp)



> 
> 2. Wrap call to stty around
> 
> if [[ -t 0 ]]; then
> 	stty ...
> fi


that worked, although maybe I'm not going about it the right way.  Any
more suggestions about my problem are welcome!  Thanks for your help.

Scott


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: remote function problems.
  2000-01-12 18:52   ` Scott Lipcon
@ 2000-01-12 19:20     ` Peter Stephenson
  2000-01-13  8:43       ` Andrej Borsenkow
  0 siblings, 1 reply; 6+ messages in thread
From: Peter Stephenson @ 2000-01-12 19:20 UTC (permalink / raw)
  To: zsh-users

Scott Lipcon wrote:
> $ ssh hostname zsh -c function
> slipcon's password:
> zsh: command not found: function
> $
> 
> this is because I load my functions in my .zshrc - they're all in a file
> called zfunc, and I say:
> 
> 
> # load functions (necessary for completions)
> [[ -r $HOME/.zsh/zfunc ]] && source $HOME/.zsh/zfunc
> 
> in my zshrc.  (which is directly before I load in my completions, which
> are in $HOME/.zsh/zcomp)

You should move the code (and anything it depends on) to ~/.zshenv and
everything will work without the -i.

-- 
Peter Stephenson <pws@pwstephenson.fsnet.co.uk>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: remote function problems.
  2000-01-12 19:20     ` Peter Stephenson
@ 2000-01-13  8:43       ` Andrej Borsenkow
  2000-01-13  9:32         ` Zefram
  0 siblings, 1 reply; 6+ messages in thread
From: Andrej Borsenkow @ 2000-01-13  8:43 UTC (permalink / raw)
  To: Peter Stephenson, zsh-users

>
> Scott Lipcon wrote:
> > $ ssh hostname zsh -c function
> > slipcon's password:
> > zsh: command not found: function
> > $
> >
> > this is because I load my functions in my .zshrc - they're all in a file
> > called zfunc, and I say:
> >
> >
> > # load functions (necessary for completions)
> > [[ -r $HOME/.zsh/zfunc ]] && source $HOME/.zsh/zfunc
> >
> > in my zshrc.  (which is directly before I load in my completions, which
> > are in $HOME/.zsh/zcomp)
>
> You should move the code (and anything it depends on) to ~/.zshenv and
> everything will work without the -i.
>


We already discussed it. IMHO it is bad idea to put this in zshenv. This will be
executed for every shell, including zsh scripts, and not ony slows it down but,
what's worse, function defintions may clash with external commands; it may
redefine some commands script relies upon; etc ... If this happens in
interactive shell, it is more or less acceptable - you get immediate feedback.
But it may cause scripts to behave in unpredictable way.

zshenv is  not needed for scripts - at least, should not be needed. Scripts
should be self-contained. Almost the only use for zshenv is to redefine/augment
default module_path as zsh simply won't be usable without it's modules. Anything
else can be setup as needed in zshrc for interactive shells or in script itself
for scripts.

Why not make your command a shell script in the first place? It could then
source whatever function definitions it needs.

/andrej


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: remote function problems.
  2000-01-13  8:43       ` Andrej Borsenkow
@ 2000-01-13  9:32         ` Zefram
  0 siblings, 0 replies; 6+ messages in thread
From: Zefram @ 2000-01-13  9:32 UTC (permalink / raw)
  To: Andrej Borsenkow; +Cc: Peter Stephenson, zsh-users

Andrej Borsenkow wrote:
>We already discussed it. IMHO it is bad idea to put this in zshenv. This will be
>executed for every shell, including zsh scripts, and not ony slows it down but,
>what's worse, function defintions may clash with external commands; it may
>redefine some commands script relies upon; etc ...

That's why zsh scripts start "#!.../zsh -f".  zshenv is the right place
to define functions.

-zefram


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2000-01-13  9:32 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-01-11  4:49 remote function problems Scott Lipcon
2000-01-12  7:29 ` Andrej Borsenkow
2000-01-12 18:52   ` Scott Lipcon
2000-01-12 19:20     ` Peter Stephenson
2000-01-13  8:43       ` Andrej Borsenkow
2000-01-13  9:32         ` Zefram

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).