From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Emanuel Berg Newsgroups: gmane.emacs.help Subject: Re: executing bash function with shell-command Date: Tue, 23 Feb 2016 01:27:05 +0100 Message-ID: <87k2lww9t2.fsf@debian.uxu> References: <20160222195831.GA22309@mortar.AMN> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1456187276 23470 80.91.229.3 (23 Feb 2016 00:27:56 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 23 Feb 2016 00:27:56 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Feb 23 01:27:44 2016 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1aY0pM-00036d-JH for geh-help-gnu-emacs@m.gmane.org; Tue, 23 Feb 2016 01:27:44 +0100 Original-Received: from localhost ([::1]:52821 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aY0pL-0006el-W9 for geh-help-gnu-emacs@m.gmane.org; Mon, 22 Feb 2016 19:27:44 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:33314) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aY0pB-0006eW-EH for help-gnu-emacs@gnu.org; Mon, 22 Feb 2016 19:27:34 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aY0p8-0007A5-6N for help-gnu-emacs@gnu.org; Mon, 22 Feb 2016 19:27:33 -0500 Original-Received: from plane.gmane.org ([80.91.229.3]:37652) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aY0p7-00079v-W7 for help-gnu-emacs@gnu.org; Mon, 22 Feb 2016 19:27:30 -0500 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1aY0p1-0002rn-6u for help-gnu-emacs@gnu.org; Tue, 23 Feb 2016 01:27:23 +0100 Original-Received: from nl106-137-54.student.uu.se ([130.243.137.54]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 23 Feb 2016 01:27:23 +0100 Original-Received: from embe8573 by nl106-137-54.student.uu.se with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 23 Feb 2016 01:27:23 +0100 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: help-gnu-emacs@gnu.org Original-Lines: 41 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: nl106-137-54.student.uu.se Mail-Copies-To: never User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) Cancel-Lock: sha1:/Ey0iRQsvUTnpbzeKPGkyB2SQDs= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:109256 Archived-At: mvar writes: > I've been trying to setup a lisp function in emacs > (24.5.1) that executes an external bash function > defined in my .bashrc file (or even .emacs_bash). > If i open the shell directly from within emacs and > type the function in there it works, but if i call > it with "shell-command" i get a "command not > found" error. It is because when you open bash from Emacs bash is the interactive shell. When you open Emacs from bash Emacs talks to a non-interactive bash where BASH_ENV is the only thing that is sourced. (Or so I've heard - I don't use bash myself - I use zsh, where you solve this by putting shared stuff in .zshenv) So try putting the shared file path in BASH_ENV, or you can even try: BASH_ENV=~/.bashrc emacs The the distinction interactive/non-interactive gets foggy but I suppose your computer won't blow up. > A workaround is to run shell-command with "source > ~/.emacs-bash && function_name". Indeed, the material is not read is the problem. > another question, is it viable to create some > function/script in Lisp that for example will ssh to > a remote machine, execute some pre-defined commands > and log-off ? The only relevant info i've found so > far is for remote editing with tramp. Yes, you can do that. -- underground experts united http://user.it.uu.se/~embe8573