I have a simple shell script that returns a file.
Shell ("c:\cygwin64\bin\bash --login '/cygdrive/c/cygwin64/home/me/bin/sp2 '" & Parm1)
This fails as a shell command but works when sent via command line
Is there anyway I can keep the cmd window open when running via the Excel shell command, to see what errors are being encountered.
Thanks
Related
I've found a very strange issue, when in linux terminal I type "enable -n trap", it would disable the trap linux builtin command. But if I put it into a script like
#!/bin/bash
enable -n trap
and then run the script, there's no error but the command is also not disabled. Really appreciate if someone could share what is happening and how to run it in some file instead of directly in the terminal. Thank you!
The enable command only affects the current shell. When you run a script, that script is executed in a new process, so:
A new shell starts
The enable command runs and disables the trap command in that shell
The shell exits
If you want to affect the current shell, your only option is to source the script using the . (or source) command. If the script is named disable-trap.sh and is in your $PATH, you can run:
. disable-trap.sh
You can also provide a full path to the script:
. /path/to/disable-trap.sh
Sourcing a script like this is largely equivalent to typing the same commands in at the command line: it executes the instructions in the script in the current shell, rather than spawning a new process.
I am using mapfile -t to obtain content of a text file and assign it to array.
In Jenkins it works fine where it will prompt steps and what command executed in console output .When I try to run in local console for example putty it prompts.
mapfile: not found [No such file or directory]
I know that mapfile is a bash command is and I am able to run the shell program after typing bash and executing the script.Is there anyway that I don't need to type bash in order to run the program ?I include #!/bin/bash -x on top of the script it still display the same error .The reason I don't want to type bash and execute the script is due to that it did not show what are the errors when the script dies.It did not display the error handling process that was in the script and it did not display output when it runs the command.
Please open a new file called script in a text editor. Type your program in:
#!/bin/bash -x
set -e
item=$1
if [ $item = '-database' ] then
mapfile -t DATA < $DATA_FILES
fi
save the file, execute chmod u+x and then
./script "-database"
to run it.
That's it.
However, that script will print nothing.
I am trying to open a terminal and run a script using matlab. The script will open an ssh connection. The matlab command is:
system(['lxterminal -e "bash ' scriptName '" &'],'-echo');
When I execute the matlab command the script runs but fails fails to validate SSL credentials.
The script is running ssh through the python paramiko package.
The error arises from the cli.py module.
The problem is solved if I run
system(['lxterminal -e "sudo bash ' scriptName '" &'],'-echo');
but then I have to enter the user password each time I execute the script.
If I open an lxterminal and run the same command:
bash scriptName
it works without the sudo.
I think it is related to some environmental variables / configuration which are not loaded in lxterminal before running the script, but cannot figure out it.
Using xterm instead of lxterminal has the same behavior.
Any ideas?
The fix, might be dirty, was to empty the LD_LIBRARY_PATH from the matlab environmental variables before calling the system command using the following command in the matlab script
setenv('LD_LIBRARY_PATH');
Probably the matlab LD_LIBRARY_PATH path is using obsolete libraries compared to the ones python needs.
A better approach might be to start removing one by one the paths until finding the one causing the problem.
How can I run a shell script in a new cygwin window? The following just opens up the windows type of cmd window which is difficult to resize.
cygstart /cygdrive/c/cygwin/bin/bash ~/runmyapp.sh
Well, if you want to keep the window open after the script exits, you have to do something to make the shell that is executing the script not exit.
Here's an example that should work.
mintty bash -c "~/runfxtransact.sh; read -p \"Press enter to close this window.\"" &
I am writing a shell script in Linux. I want to run some sh files in terminal and they all needs terminal themselves.
How can I open a new terminal to run another scrips?
xterm -e script arguments... &