is there a way to create shortcuts for a list of windows commands? - command-line

Not very sure if this is the right way of asking, but I was wondering if it is at all possible to "bunch/combine" these commands:
cd %webapps%
cls
mvn clean install
copy etc\environment\dev\yao\env.conf.bat webapps-dist\target\classes
yes
cd %jboss%
run.bat -c server -b 0.0.0.0
shutdown.bat -S
into ONE command like: %runserver% or something like that?
Also, is there a way to get rid of the prompt when I try to copy a file?
I literally do this every time I reinstall my apps, so a shortcut would be amazing.
I already just copy and paste these commands, but I'm lazy so I want shorter commands.

If you are running these commands from the same location, you can make a batch file and just run the batch file.

Related

BiqQuery detected on windows command prompt but not on Bash

I've installed Cloud SDK on my windows 10 machine and I'm able to run commands like "gcloud", "gsutil" and "bq" on my command prompt. However, when I run "gsutil" or "bq" on Bash, this is the error I'm getting.
$ bq
bash: bq: command not found
Then I added this location to PATH C:\Users\User\AppData\Local\Google\Cloud SDK\google-cloud-sdk\bin, and afterwards I seem to be able to call gsutil and bq using gsutil.cmd and bq.cmd. But of course, I'd prefer calling bq / gsutil directly.
Has anyone has this problem before? Thank you!
I found one possible solution!
In Bash, go to the root bash folder by typing cd
Type touch .bashrc
write alias bq="bq.cmd" or alias gsutil="gsutil.cmd" or both
Press Esc and type :qa and Enter to save and exit
This tells Bash to remember bq as invoking bq.cmd, hence now I can invoke bq anywhere -- as far as I know.
If anyone has a better suggestion, please let me know! Thank you!
In the bash session itself, check what echo $PATH returns. It should inherit the path that was defined on Windows.
So open a new CMD session, and:
make sure the %PATH% does include C:\Users\User\AppData\Local\Google\Cloud SDK\google-cloud-sdk\bin,
then call C:\path\to\Git\bin\bash.exe to open a bash session
bq should work in such a shell session.

Creating a bat file to run raspberry pi commands on windows

I am trying to set up a simple bat file to help non-tech people execute scripts by just clicking a file on desktop.
I haven't used windows in a while, and don't have a real dev environment set up on the computers they are going to be using. I installed putty, and can manually ssh into the pi's and run commands, but I can't teach that process to the employees.
I would like to create a simple bat file that runs the following commands:
ssh pi#192.168.1.xxx
<enter password>: 'xxx'
sudo reboot
Is there a way to do this?
Thank you!
Downloaded Plink #
https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html
I moved it, AND putty to c:/windows/system32 instead of changing PATH
This doesn't seem necessary, as the next step will automatically locate the file and change the path.
On desktop, right click and create a new shortcut.
In the shortcut path, I typed:
plink -ssh username#192.16.1.xxx -pw raspberry sudo reboot
This worked.
if you recheck the shortcut again, it should automatically change the path to execute plink

Installing Meteor - Couldn't write the launcher script

I am front-end developer attempting to crossover into the world of web app development. I've come a long way in learning Javascript, and now I'm looking to toy around with frameworks.
I still have a bit to learn about using the OSX terminal, but I was hoping somebody could help me with this first stumble I'm having....
I try to install meteor using:
$ curl https://install.meteor.com | /bin/sh
Then I get the following:
Meteor 0.6.4 has been installed in your home directory (~/.meteor).
Writing a launcher script to /usr/local/bin/meteor for your convenience.
This may prompt for your password.
cp: /usr/local/bin/meteor: No such file or directory
Couldn't write the launcher script. Please either:
(1) Run the following as root:
cp ~/.meteor/tools/latest/launch-meteor /usr/bin/meteor
(2) Add ~/.meteor to your path, or
(3) Rerun this command to try again.
Then to get started, take a look at 'meteor --help' or see the docs at
docs.meteor.com.
If it's still helpful to anyone, going into /usr/local/bin, running "sudo rm meteor" then running the install gets it to work for me
Yeah try one of the three suggestions or:
sudo curl https://install.meteor.com | /bin/sh
I had the same problem heres how I fixed it!
Delete all meteor folders
In finder (cmd +shft+g)
type in "~/.meteor"
on the top of the finder window where is has the folder.meteor click and drag folder to trash
In finder (cmd +shft+g) type in "/usr/bin/meteor" then drag the meteor folder to trash
3.In /usr/ create a new folder "local" (password required) and inside "local" create a folder "bin"
Go back to terminal a run curl https://install.meteor.com | /bin/sh

Permission denied (publickey,keyboard-interactive)

Permission denied (publickey,keyboard-interactive) got this error while i am trying to cvs checkout from perl.
what is issue and how to reslove this ?
Code :
system ( "CSVROOT:--- CVSRSH:--- cvs co a ");
# i have proper value in cvs root and cvs rsh .
its running alone and using ssh key
Steps to diagnose the error:
Are you using an SSH key?
Does that key have a passphrase?
Does it work when you run it by hand?
Is the script running as the same user as when you run it by hand?
Is the script running under the same environment as when you run it by hand? (e.g. cron jobs do not run under the same environment)
If you think all of the answers are yes, then most likely the last answer is really no. If the script is running from a scheduler like cron it most likely does not run with the same environment as when you run it by hand. The way I normally solve this is to use a shell script between the scheduler and the Perl script:
#!/bin/bash
source /home/USERNAME/.profile
#set any other environment variables it needs like
export CSVROOT=:pserver:USERNAME#HOST:/path/to/repo
export CVSRSH=ssh
/path/to/perl/script/script.pl
Follow-up investigations after Chas.'s questions:
Does that command normally run under /bin/sh or some other shell?
To test, execute /bin/sh command to start Bourne shell and try the command by hand again.
I'm not familiar with "CVSROOT:---" notation - is that meant to set CVSROOT environmental variable? In Bourne shell it's usually done using "=", never saw ":" used.
Does the command, when run by hand, expect some input from you? I never saw cvs co to do so, but I don't use it with ssh.
Try to add a redirect to the end of the command and look what's in the file after running:
system ( "CSVROOT:--- CVSRSH:--- cvs co a > /tmp/log_cmd 2>&1");

Cygwin - run script silenty from "run command"

I have script lets say:
C:\foo.bsh
I want to be able to run this command via the windows run command:
Start -> Run
Windows Key + R
and type something small like 'foo' and hitting return.
However, I do not want a cmd prompt to be visible. This script does some preprocessing for an IDE. I do not want the cmd prompt to be open for the lifetime of the IDE process.
I have tried:
1) Creating a bat file with the following contents:
c:\cygwin\bin\bash --login "C:\foo.bsh" (this fails because it keeps a cmd open)
2) Converting the above bat file to an exe using bat_2_exe_converter (does not make the cmd silent)
thoughts?
EDIT: The solution so far suggests something to type from an actual cygwin shell. I am trying to get a faster solution by having something short I can type in the Windows run command. Also, the nohup command; exit doesn't automatically kill the box - however I can manually kill it without killing the IDE process. The run command accepts shortcuts (.lnk's), bat's, exe's.
Try the run.exe command of cygwin. It is a big install, a complete unix environment for your Windows machine. Suppose you installed it at c:\cygwin\.
No mystery, just run c:\cygwin\bin\run.exe <your command here> and you will have your no dos window execution.
You can run it from any DOS window (run cmd.exe from the start menu). You don't need to run it from cygwin.
To make it easier, append C:\cygwin\bin to your %PATH% env var (My Computer → Properties → Advanced → Environment Variables) (Kudos to Felipe Alvarez comment).
Now you can just type
c:\cygwin\bin\run.exe "C:\foo.bsh"
You must create a link in your Start Menu with this command so will be able to run it with Win-R.
Here is the man page of the runcommand:
$ man run
RUN(1) run 1.3.0 RUN(1)
NAME
run - start programs with hidden console window
SYNOPSIS
run [ -p path ] command [ -wait ] arguments
runcommand [ -p path ] [ -wait ] arguments
DESCRIPTION
Windows programs are either GUI programs or console programs. When
started console programs will either attach to an existing console
or create a new one. GUI programs can never attach to an exiting con‐
sole. There is no way to attach to an existing console but hide it if
started as GUI program.
run will do this for you. It works as intermediate and starts a pro‐
gram but makes the console window hidden.
With -p path you can add path to the PATH environment variable.
Issuing -wait as first program argument will make run wait for program
completition, otherwise it returns immediately.
The second variant is for creating wrappers. If the executable is
named runcommand (eg runemacs), run will try to start the program (eg
emacs).
EXAMPLES
run -p /usr/X11R6/bin xterm
run emacs -wait
runemacs -wait
run make -wait
AUTHORS
Charles S. Wilson
Harold L Hunt II
Jehan Bing
Alexander Gottwald
Version 1.3.0 November 2005 RUN(1)
You can use either...
c:\cygwin\bin\bash -l /path/to/script_to_interpret.sh
...or...
c:\cygwin\bin\bash -l -c /path/to/executable_script.sh
Note: the -l flag tell bash to "act as if it had been directly invoked by login" and use Bash Startup Files. This is important in that it sets your $PATH and other things you rely on when you launch a cygwin terminal. If you don't include -l or --login you will get "command not found" when you try to call anything except of a bash builtin.
The difference between the 2 is like the difference between doing...
bash script_to_interpret.sh
...and...
./executable_script.sh
...in *nix. The former interprets the script using bash. The latter executes the script (only if it has chmod +x executable_script.sh) and interprets it according to its "shebang" line. The latter method is also what you want to do if your executable is not a script at all, like a *nix binary compiled from source.)
It has been bugging me for a while I couldn't find the solution for this, but I finally got the right mix together.
You can simply do the following if you have cygwin on your PATH:
run bash test.js
If cygwin is not on your path, you can do this:
c:\cygwin\bin\run.exe -p /bin bash test.js
If you are looking for more control over the created window (maximize, etc) it looks like you can use cygstart also.
Sources:
- neves answer above (though that wasn't enough by itself for me personally to figure it out)
- http://cygwin.com/ml/cygwin/2008-09/msg00156.html
As the terminal can't close while your script is still running, try the command:
"nohup C:\foo.bsh; exit"
This way your script will be backgrounded and detached from the terminal, and it should exit quickly so the terminal goes away. I think that the window may still 'flash' with this approach, but the results should be better than what you're getting.
I'm running Cygwin64 and the xwin server link points to:
C:\cygwin64\bin\run.exe /usr/bin/bash.exe -l -c /usr/bin/startxwin.exe
This creates an icon AND a notification on the taskbar. I don't like that. The icon is rather useless, the notification has all your menu options from .XWinrc.
So... I wrote a .vbs script to silently run this command and make the icon go away:
Set objShell = CreateObject("WScript.Shell")
objShell.Run("C:\cygwin64\bin\run.exe /usr/bin/bash.exe -l -c /usr/bin/startxwin.exe"), 0
Another imperfect possibility is to run the script via a shortcut and set the shortcut's Run option to "minimized".
Go to the directory where you have installed cygwin(on my machine it is c:/cygwin64/bin)
Once there simply type "bash.exe"