is it possible to use variables in remote ssh command?

I'd like to execute several commands in sequence on a remote machine, and some of the later commands depend on earlier ones. In the simplest possible example I get this: ssh my_server "echo this is my_server; abc=2;" this is my_server abc=2: Command not found. ssh my_server "echo this is my_server; abc=2; echo abc is $abc" abc: undefined variable For a bit of background info, what I actual

是否有可能在远程SSH命令中使用变量?

我想在远程机器上按顺序执行几个命令,而后面的一些命令依赖于以前的命令。 在最简单的例子中,我得到了这个: ssh my_server "echo this is my_server; abc=2;" this is my_server abc=2: Command not found. ssh my_server "echo this is my_server; abc=2; echo abc is $abc" abc: undefined variable 对于一些背景信息,我真正想做的是拼凑一条路径并启动一个Java应用程序: ssh my_server 'nohup sh -c "( ( echo this i

Need to execute a shell script in different unix servers

雅博官网在线注册雅博体育锁定账户雅博国际顶级 This question already has an answer here: How to use SSH to run a shell script on a remote machine? 11 answers I would suggest 4 different ways of doing it, 1. The easiest way : configure space cleanup script in crontab 2. Call script in remote servers from one server via ssh . see this link how-to-use-ssh-to-run-a-shell-script-on-a-remote-machine 3. Run a script which keep on looking

需要在不同的Unix雅博国际顶级上执行一个shell脚本

这个问题在这里已经有了答案: 如何使用SSH在远程机器上运行shell脚本? 11个答案 我会建议4种不同的做法, 1.最简单的方法:在crontab配置空间清理脚本 2.通过ssh从一台雅博国际顶级调用远程雅博国际顶级中的脚本。 请参阅此链接how-to-use-ssh-to-run-a-shell-script-on-a-remote-machine 3.运行一个script ,在某个位置继续查找status/trigger file (虚拟文件),并在需要时将虚拟文件(ftp,scp等)从一台雅博国际顶级推送到该特

What are the uses of the exec command in shell scripts?

任何人都可以用简单的例子来解释exec命令在shell脚本中的用途吗? The exec built-in command mirrors functions in the kernel, there are a family of them based on execve , which is usually called from C. exec replaces the current program in the current process, without fork ing a new process. It is not something you would use in every script you write, but it comes in handy on occasion. Here are so

exec脚本在shell脚本中有什么用处?

任何人都可以用简单的例子来解释exec命令在shell脚本中的用途吗? exec内置命令镜像内核中的函数,有一个基于execve ,它通常从C中调用。 exec取代当前进程中的当前程序,而无需fork新的进程。 这不是你在每个你写的脚本中都会用到的东西,但它偶尔会派上用场。 以下是我使用过的一些场景; 我们希望用户在不访问shell的情况下运行特定的应用程序。 我们可以在/ etc / passwd中更改登录程序,但也许我们希望从启动文件中使

Using getopts in bash shell script to get long and short command line options

I wish to have long and short forms of command line options invoked using my shell script. I know that getopts can be used, but like in Perl, I have not been able to do the same with shell. Any ideas on how this can be done, so that I can use options like: ./shell.sh --copyfile abc.pl /tmp/ ./shell.sh -c abc.pl /tmp/ In the above, both the commands mean the same thing to my shell, but using

在bash shell脚本中使用getopts来获取长命令和短命令行选项

我希望使用我的shell脚本调用多种形式的命令行选项。 我知道可以使用getopts ,但就像在Perl中一样,我还没有能够对shell执行相同的操作。 关于如何完成这些任何想法,以便我可以使用如下选项: ./shell.sh --copyfile abc.pl /tmp/ ./shell.sh -c abc.pl /tmp/ 在上面,这两个命令对我的shell来说意味着相同的东西,但是使用getopts ,我还没有能够实现这些? bash getopts builtin不支持带有双点划线前缀的长选项名称

How to schedule a task wether the user is logged on or not in PowerShell?

I have a problem regarding how to make a scheduled task to run whether the user is logged on or not. It must be done in powershell. What i have done is: $WINDIR/system32/schtasks.exe /create /tn TaskName /sc daily /st 15:05:00 /tr "C:cygwinoptIBMtpchcbintoolsTheFileToRun.bat" But can i provide an extra argument making this task run no matter if the user is logged on or off? If it cant be do

如何计划用户登录或不在PowerShell中的任务?

我有一个关于如何使计划任务运行的问题,无论用户是否登录。 它必须在PowerShell中完成。 我所做的是: $WINDIR/system32/schtasks.exe /create /tn TaskName /sc daily /st 15:05:00 /tr "C:cygwinoptIBMtpchcbintoolsTheFileToRun.bat" 但是,我可以提供额外的参数,无论用户登录还是关闭,都可以运行此任务。 如果它不能在Powershell中完成,那么可以用另一种脚本语言来完成它? 谢谢 :) 你需要指定一个用户(比

Get Spacemacs/Emacs GUI version to recognize nix

I do my development in a Nix shell (create a default.nix file in my project root and then run nix-shell . to give me a shell with access to the project dependencies). Spacemacs is my main editor, but when I try to run the GUI version via emacs & I don't have access to the programs in my nix-shell (if I were in a Ruby on Rails project for example, and Ruby was declared as a dependency in

获取Spacemacs / Emacs GUI版本以识别nix

我在Nix shell中进行开发(在我的项目根目录下创建一个default.nix文件,然后运行nix-shell . ,为我提供一个可以访问项目依赖项的shell)。 Spacemacs是我的主要编辑器,但是当我尝试通过emacs &运行GUI版本时emacs &我无法访问我的nix-shell中的程序(例如,如果我在Ruby on Rails项目中,并且Ruby被声明为在我的default.nix有一个依赖项,因为Emacs的GUI版本没有看到我的Nix-shell依赖关系,所以我在Spacemacs中没

Ignore directory path in find (in shell)

This question already has an answer here: How to exclude a directory in find . command 32 answers 您可以使用-regex选项: find -type f ! -regex '.*/media/.*'

忽略find中的目录路径(在shell中)

这个问题在这里已经有了答案: 如何在find中排除目录。 命令32个答案 您可以使用-regex选项: find -type f ! -regex '.*/media/.*'

How exclude files / folders for remove

This question already has an answer here: How to exclude a directory in find . command 32 answers 注意:小心运行以下命令。 find . -type 'f' | grep -v "NameToExclude" | xargs rm find . -type 'd' | grep -v "NameToExclude" | xargs rmdir The rm function does not have an exclude function. Instead you can use rm *.txt to delete only text files, rm *.pdf to delete only PDF files, rm a* to delete

如何排除要删除的文件/文件夹

这个问题在这里已经有了答案: 如何在find中排除目录。 命令32个答案 注意:小心运行以下命令。 find . -type 'f' | grep -v "NameToExclude" | xargs rm find . -type 'd' | grep -v "NameToExclude" | xargs rmdir rm函数没有排除功能。 相反,您可以使用rm *.txt删除文本文件, rm *.pdf删除仅PDF文件, rm a*删除仅以字母a开头的文件, rm *d删除仅以字母d结尾的文件,等等 使用这种方法,你可以相对快速地删除除了

How can I reverse the order of lines in a file?

I'd like to reverse the order of lines in a text file (or stdin), preserving the contents of each line. So, ie, starting with: foo bar baz I'd like to end up with baz bar foo Is there a standard UNIX commandline utility for this? BSD tail: tail -r myfile.txt Reference: FreeBSD, NetBSD, OpenBSD and OS X manual pages. Also worth mentioning: tac (the, ahem, reverse of cat ). Par

我怎样才能扭转文件中的行的顺序?

我想倒转文本文件(或标准输入)中行的顺序,保留每行的内容。 所以,即从以下开始: foo bar baz 我想结束 baz bar foo 有没有一个标准的UNIX命令行工具? BSD尾巴: tail -r myfile.txt 参考:FreeBSD,NetBSD,OpenBSD和OS X手册页。 另外值得一提的是: tac (the,ahem,反向的cat )。 部分coreutils。 将一个文件翻转成另一个文件 tac a.txt > b.txt 有一些众所周知的sed技巧: # reverse order of l

debugging /etc/init.d startup scripts in Ubuntu

Have custom dropr message queue pollers I'm trying to start up via /etc/init.d in ubuntu. All 3 scripts are super-simple one liners and work perfect via command line, but for some reason, only one of them actually works when the server boots up. All have 775 perms, and this works great: sudo /etc/init.d/app-poller.sh Here's an example script (has to run as www-data user): [/etc/init

在Ubuntu中调试/etc/init.d启动脚本

有定制的dropr消息队列轮询我试图通过/etc/init.d在Ubuntu中启动。 所有3个脚本都非常简单,通过命令行可以完美工作,但出于某种原因,只有其中一个脚本在雅博国际顶级引导时起作用。 所有有775烫发,并且这工作伟大: sudo /etc/init.d/app-poller.sh 以下是一个示例脚本(必须以www数据用户身份运行): [/etc/init.d]$ cat /etc/init.d/app-poller.sh #!/bin/sh su - www-data -c "bash -c '/path/to/dropr-server/daemons/a