Call a MobaXterm command from a bash script - bash

From my /home/mobaxterm command prompt, I can use the newtab "command" to launch a new tab and execute a command just fine. When I use it inside a bash script, I get "newtab: command not found".
Is there special coding required to use the MobaXterm commandline parameters as found here: https://blog.mobatek.net/post/mobaxterm-command-lines/ inside a bash script?
Thanks.

Use this
/bin/MobaSendMsg.exe MobaXterm -newtab "YOUR_COMMAND"

Related

Keep terminal open at the end of bash script

I'm trying to run a bash script from cmd. When I execute the script a new terminal is opened an immediately closed since there is some problem with it. Because its happening so fast I can't read the problem. I'm looking for a way to keep the terminal open once the script exits.
Go horribly Windows-y with this:
read -p "Press any key to continue" x
You can also put a $SHELL in a new line at the end of your script. The window will stay open, no matter from where you open your shell script (e.g. cmd / powershell / etc).
Add bash at the end of the script
It works for me.
to test a .sh script in windows cmd (assuming you have bash installed and in your path environment variable):
cd into parent directory,
type "bash" to enter bash console,
type "./",
type "exit" to exit bash console

how to write a batch (windows) to start Cygwin (mintty.exe) and then execute a python script?

Pretty much as titled. If I were to manually do this, I would first open a Cygwin Terminal (which should be /cygwin/bin/mintty.exe), and then in that terminal, cd to the directory that has the python script, and then execute the python script by doing "python myPython.py". I'm wondering if I can write a batch script or a bash script to do this: start a Cygwin Terminal, cd to a directory, execute a python script in the directory.
Thanks.
Edited:
So I have a python script that generates csv files for activities through mongodb.This script won't function if I run it through windows cmd. I have to run it in cygwin terminal (mintty.exe). So any alternatives to execute the python script won't work. I have to somehow start a Cygwin Terminal and execute the python script through there. Any ideas please? Thanks.
Depending of your needs it could be better to start mintty (creating a new window) instead of starting bash inside the cmd.exe window.
When you want to use ansi escape sequences then it works better with a real mintty window, as the cmd window ignores the escape sequences for window resizing and positioning.
start "" C:\cygwin\bin\mintty --exec ./myProgramToExecute.sh
You may start a bash from the Windows terminal and start your script from there (without starting mintty.exe). Just execute
bash -c "cd /your/directory && python myPython.py"
from the Windows cmd prompt or a batch file.

"source: command not found" running script with git sh via cmder

I'm using cmder on windows https://github.com/bliker/cmder
I created my custom cmder task with the following commands
-new_console:d:C:\project > "C:\Program Files (x86)\Git\bin\sh.exe" --login -i -cur_console:d:C:\project
I need to add another command when this tab opens
source script.sh
But when I add it above in the commands I get
'source' is not recognized as an internal or external command
You can use -c to pass a command to sh to have it run that but I don't believe you can do that and get an interactive session.
Which means if you need a command to be run at the start of an interactive session you want to use the --init-file or --rcfile to specify your startup file (instead of the default file). Though those might both be bash specific. I'm not sure.
If they are then you could try setting the ENV variable to the (absolute or variable/etc. expansion-able) path to your script before running the shell.

call perl script in cygwin

I would like to start perl.pl within a cygwin terminal such that perl.pl starts in a new cygwin terminal.
What is the best way to do this?
So far I've tried to use system(perl.pl) and exec(perl.pl), but that runs the perl script within the windows command line, not cygwin.
As you can see by viewing the properties of the shortcut, the command that opens the terminal is
mintty.exe -i /Cygwin-Terminal.ico -s 105,60 -
So you'd run
system('mintty perl.pl');
Use command xterm:
xterm -hold -e perl.pl

run terminal commands from quicksilver

I know there is a Terminal plugin for quicksilver but I would invoke terminal commands which basically just runs in the background and never popups a terminal window. is that possible?
UPDATE:
I have the following code in my applescript but its giving me an error:
do shell script "/path/to/shell.sh blah"
error:
curses.setupterm()
_curses.error: setupterm: could not find terminfo database
In Quicksilver you can use the action "Run Command in Shell", which is part of the "Terminal Module". The command is run without showing a window. Search on the quoted terms and you'll find some examples.
Applescript is the simple solution, see:
http://developer.apple.com/library/mac/#technotes/tn2002/tn2065.html
Sample:
do shell script "ifconfig"
do shell script "ifconfig" user name "Anne" password "p#ssw0rd" with administrator privileges
Automator can also run shell scripts in the background.
If you are familiar with XCode, you can use NSTask with Objective-C.
Hold on a sec, is your shell script a bash shell script? In your first line do you have:
#!/bin/bash
If not, add that line to your script.
Also instead of just
do shell script "/path/to/yourscript.sh"
consider this:
do shell script "/bin/bash /path/to/yourscript.sh"

Resources