In a cshell script, I spin-out an xterm. From the shell where the script is executed from, I wish to execute a command (eg: banner master win) in the xterm that has been spun out from the script.
Can you suggest me a way to do that?
Do you think finding for xterm's paid would help me in this case?
Just use the -e argument to the xterm when you start it
From the output of xterm --help
[-e command args ...]
So running the following will launch an xterm to run the watch command against the date program, with a suitable title:
xterm -T "Date" -e watch date &
Related
I need to open the Mac Terminal and run some commands with os.execute in Lua
export VAMP_PATH=/path/to/plugin/directory
cd /path/to/script
./sonic-annotator -l
EDIT: got it to work without terminal with this
os.execute('export VAMP_PATH="'..script_path..'sonic/mac64/vamp"; cd "'..script_path..'sonic/mac64/"; ./sonic-annotator -d vamp:qm-vamp-plugins:qm-barbeattracker:beats -w csv "'..filename..'"')
To answer your actual question, you can start a Terminal and run some bash commands in it like this:
os.execute("osascript -e 'tell application \"Terminal\" to do script \"cd /Users/mark && ls\"'")
But, as I said in the comments, you don't necessarily need a Terminal to run a script, so you can just run a command like this:
os.execute("export V=fred; cd /Users/mark && ./SomeScript.sh")
If you are running a script because you just want the user to see the output of the script, it is often easier and involves far less quoting if you run your command and pipe the result to open -f like this, which displays the output in a text editor:
os.execute("cd /Users/mark; ls | open -f")
What I want is to open default shell, then call another and execute a command there.
Was trying something like this:
c:/Windows/System32/bash.exe -c "zsh & zstyle"
or
cmd /k "c:/Windows/System32/bash.exe -c zsh" & zstyle - this open shell but doesn't run a commands
or
c:/Windows/System32/bash.exe -c "zsh -c 'zstyle'"
Currently I am using a cmder/conemu terminal for windows.
Unfortunately, passing a startup to command to zsh with -c and keeping it open for interactive use (with -i) doesn't work.
Disclaimer: The following solutions were tested from a regular Command Prompt (cmd.exe), not cmder/conemu, though I'd expect them to work there too.
To try them from PowerShell (v3+), insert --% as the first argument after (right after bash.exe).
Here's a workaround:
c:/Windows/System32/bash.exe -c "zsh -c 'zstyle' && exec zsh -i"
Note that command zstyle is executed in a different, transient zsh instance, so this approach won't work for commands whose purpose is to modify the environment of the interactive shell that stays open.
If that is a requirement, things get more complicated (this solution courtesy of this answer):
c:/Windows/System32/bash.exe -c "{ { echo 'zstyle'; echo 'exec 0<&3-';} | zsh -i; } 3<&0"
Note, however, that both commands being executed will be printed before their output, if any, is shown, preceded by the prompt - as if the commands had been typed interactively.
For the first time I'm just playing around with nohup on top of an Ubuntu server. I read few docs about nohup and got to know about the running commands with options such as nohup ./server.sh &.
What I want to know is that, how should I be running the JMeter script (in headless mode) using nohup? Following is the script I needed to run with nohup:
./jmeter.sh -n -t /home/chamith/WSO2MB/new/apache-jmeter-2.13/bin/GamesSubscriber.jmx
When I tried using the normal nohup operation within the script it always throws me an error saying -n command not found. How should I move on with this? Any help would be appreciated.
Although I cannot reproduce your issue you can try surrounding your command with quotation marks like:
nohup "./jmeter.sh -n -t /home/chamith/WSO2MB/new/apache-jmeter-2.13/bin/GamesSubscriber.jmx"
Also don't forget -l key to save the results into a file.
The full command which runs script totally in the background will look like:
nohup "./jmeter.sh -n -t /home/chamith/WSO2MB/new/apache-jmeter-2.13/bin/GamesSubscriber.jmx -l result.jtl" > /dev/null 2>&1 &
References:
nohup man page
nohup Execute Commands After You Exit From a Shell Prompt
How Do I Run JMeter in Non-GUI Mode?
Full list of JMeter command-line options
In this expect script there will be no ssh server connected, I just want to execute a ".sh" file locally, is that possible?
For instance:
#!/bin/expect
command "xxx.sh" # a command which starts a certain shell script
Also, is it possible to execute a expect script within a expect script?
For instance:
#!/bin/expect
command "xxx.exp" # a command which starts a certain expect script
Any help?
If you need to interact with this script, use spawn xxx.sh
If you just need to run it and capture the output, use set output [exec xxx.sh]
Expect is an extension of the Tcl language, so you would be well served to go through the Tcl tutorial.
The command in Expect to run a shell command is spawn.
#!/bin/expect
spawn command arg1 arg2 ...
command can be any program -- a binary executable, a shell script, another expect script, etc. So you can do:
spawn xxx.sh
or:
spawn xxx.exp
I want to run a program from inside a bash script, such that it opens in a new command line window. How can I do this?
That really depends on the GUI you are using. Try some of the below for executing an ls command.
With gnome-terminal:
gnome-terminal -x bash -c "ls; bash"
(taken from http://www.linuxquestions.org/questions/programming-9/is-command-line-invocation-of-gnome-terminal-to-run-more-than-one-command-possible-789599/)
With xterm:
xterm -e "ls; bash"
(taken from http://ubuntuforums.org/showthread.php?t=760006).
For konsole, take a look here:
http://mandrivausers.org/index.php?/topic/28128-opening-tabs-in-konsole-from-script/
or here:
http://lwn.net/Articles/88410/
xterm -e 'program to be run'
Your terminal may have a different switch than -e, but I don't know what your terminal is.