Calling the below bash script from Jenkins pipeline but I don't see the script execution on Jenkins console, can someone please advise how to display execution on jenkins console, bash script execution which is running on cygwin(on windows agent)
bat'call D:\cygwin64\bin\mintty.exe /usr/bin/bash -lic \"/home/test.sh\" '
One possible way to accomplish this is to go to "Manage Jenkins", "Configure System", and change the "Shell executable" parameter to your cygwin bash address. As your example shows, something like D:\cygwin64\bin\bash.exe. Then, on the job configuration, you can select on "Build", "Execute Shell". You can paste your test.sh script content in there. Like this:
With this configuration, Jenkins will run whatever you pasted in the "Execute shell" screen using the bash.exe address you provided in the configuration. I believe this is the most seamless way to execute shell scripts on Jenkins running on windows. The output looks almost Linux native:
Related
I have this myscript.sh act as a performance monitor in Windows Server. To do so, I'm using Git Bash to run the script but the problem is the script just execute it once after I put the command to run it. Is there any command that I can use to run it in daemon or maybe let the script run periodically based on our time interval?
How to mark a configured shell script to executed command in Azure VM Custom Script Extension ?
It is running the shell commands in configured CSE but it has not ending up the script due to one of my command. My command will be running a small HTTP listener kind of server.
If make "exit 0" will mark CSE as command executed and so it will exits in my powershell script where i encountered this CSE.
If my understanding is right. You could run HTTP listener in the background and exit your script. Just use below:
nohup <bash shell> &
man nohup
nohup - run a command immune to hangups, with output to a non-tty
& to the command line to run in the background:
Can I create a slack bot or a custom command to run a bash command or script from slack?
You can use Slack Remote Terminal to run a bash command or script (; separated) from slack, also you will get alerts about large tasks.
You can't execute a bash command or script directly from a Slack integration, but you could do so indirectly. For example, you could create a slash command that executes a command URL on a host that you control. When that command URL is executed, your host can then run whatever commands or sequences you want on that host.
But it would be very difficult, but not necessarily impossible, to ultimately execute a script on your local machine.
I have scheduled a task in windows server 2008R2 ..I want to run a VBScript so when I setup the task I call the cscript at C:\Windows\System32\cscript.exe and in the arguments section I am passing //nologo //B d:\main\programs\copy.vbs /targets:contents but it is not executing my script ..If I call my script directly in the start program section it works fine but it's not working if I call CSrcipt and pass in arguments the status changes to queued but nothing happens after that..Can someone tell me what I am doing wrong here.
Also another question I have is that can we run 2 programs one after another in one task like when one script is finished I would like to start another script .
Thanks
Put this line at the top of your script and try again:
CreateObject("WScript.Shell").LogEvent 4, "Script running"
Unless you get an Information event with source WSH and event-ID 4, your script isn't running at all. Check the eventlog and the task's History tab for clues as to why that is. Also check the permissions of the script. Is the runas account of the task able to access/run the file? You can check that by starting a CMD instance as that user
runas /user:DOM\USER cmd
and then trying to run the script in that CMD instance.
Also double-check the task settings. As which user is it configured to run? With the user logged on or not logged on? Is "Run with highest privileges" enabled (in case UAC is enabled on your server)?
If the script does produce the abovementioned event that means it's running in principle, but something is going wrong in the process. You need to debug your script.
There is an interactive shell console, I can get into it, run specific set of commands inside the console and exit from it.
Now I want to write a bash script that connects to an interactive shell console and runs my commands silently, exits at the end without any interaction. This means I want to have everything automated in a non-interactive way. Any ideas how can I achieve this?
I am trying something like, say, blabla shell is the interactive console here, it always bring me to the interactive mode :(
/usr/bin/blabla shell << EOF
do A,
do B,
do C
quit
EOF
I have a long/specific version of this question can be found here ->
Configure flume in shell/bash script - avoid interactive flume shell console
Closing stdin should do the trick:
exec <&-
The expect command if your friend. It can emulate interactive communication with other commands even in very sophisticated way.
From man expect:
Expect is a program that "talks" to other interactive programs according to a script.
You can try putting the commands you would input in the interactive prompt into a file, then run the command like:
command < file
Maybe the Secure SHell, ssh does what you need. It requires that the "remote" machine is configured as an SSH server. I use it regularly to run commands on other hosts, such as
ssh user#host command