Unable to DOS commands using Power shell on Windows 10 - powershell-2.0

In my process document I run below mentioned commands from command prompt and it works fine from command prompt but it does not work when I run these commands from Power Shell.
c:\temp\sig.csv sig.csv has input file.
I want this command to be executed silently and it takes input from sig.csv file located in temp folder.
Below is the link which I am following but using powershell.
https://www.paloaltonetworks.com/documentation/40/endpoint/endpoint-admin-guide/manage-traps-in-a-vdi-environment/configure-the-master-policy/traps-vdi-tool-cli.html
Dos Command:
TrapsVdiTool -i:c:\temp\sig.csv -e:192.168.70.100 -ssl -to:1
I run it using cmd.exe also tried executing using using &
& TrapsVdiTool -i:c:\temp\sig.csv -e:192.168.70.100 -ssl -to:1
cmd.exe /c "TrapsVdiTool -i:c:\temp\sig.csv -e:192.168.70.100 -ssl -to:1"

In the Powershell console it should run this way:
& TrapsVdiTool '-i:c:\temp\sig.csv' '-e:192.168.70.100' '-ssl' '-to:1'
Powershell: Running Executables

Related

Twilio CLI setup; In autocomplete: What is "add the autocomplete env var to your bash profile and source it"?

I'm following the CLI setup for twilio and i get the following instruction from the command line on my mac (mojave) when i reach the autocomplete section of this document (https://www.twilio.com/docs/twilio-cli/quickstart). I do not know what i am being instructed to do here. Excuse my naivety.
1) Add the autocomplete env var to your bash profile and source it
$ printf "$(twilio autocomplete:script bash)" >> ~/.bashrc; source ~/.bashrc
NOTE: If your terminal starts as a login shell you may need to print the init script into ~/.bash_profile or ~/.profile.
2) Test it out, e.g.:
$ twilio <TAB><TAB> # Command completion
$ twilio command --<TAB><TAB> # Flag completion
Enjoy!
You can run the command:
printf "$(twilio autocomplete:script bash)" >> ~/.bashrc; source ~/.bashrc
from your OS-X terminal prompt, it will then append >> the output of that command to your ~/.bashrcfile. It then sources the contents of that file to populate your terminal environment (do you don't need to close your terminal and re-open it in this first instance).
From that point on, when you start a new Bash shell, you will be good to go (and don't need to run that command again).

Can't use commands from ipython or julia repls with zsh

When I try to run a shell command in ipython or the julia repl it just says
shell> ls
zsh:1: command not found: ls
Not sure if it matters, but I have my path set in zshenv instead of zshrc so that emacs shell works.
Any ideas?
Edit:
I'm on macOS 10.14.6
For Julia, The shell> REPL prompt does in fact use a shell to execute its commands (on non-Windows systems). It effectively does something like run(`$shell -c ls`), and for most shells (including zsh) this means "non-interactive" mode and limits the number of init files that get loaded. You want to make sure your shell is working in this mode; I'd guess that if you type zsh -c ls at your terminal it'll be similarly broken.
Alternatively, you can customize which shell Julia uses through an environment variable. Setting JULIA_SHELL=/bin/sh is probably a safe bet — Julia uses that environment variable if it is set, otherwise it uses SHELL, and finally it falls back to /bin/sh if neither is set.
I'm not as familiar with ipython, but I'd wager it's doing something similar.

wscript access denied but cscript works

I have a simple vbs script that popups a message
Msgbox("Here")
I can run it using cscript
cscript hello.vbs
and it works fine. But if I try to run it using wscript, I get an error saying "Access is denied". How can I get it to run with wscript?
thanks
Cscript.exe is a command-line version of the Windows Script Host.
By Design "Windows Script Host supports scripts written in VBScript or JScript.".
It can run hello.vbs because this file is a VB Script.
And again by design, I cannot run a WScript which is a windows Shell script.
WScript by itself can be executed and does not need other programs to run it.

I have to run "/bin/bash --login" everytime to use rake/rails commands?

whenever I switch directory in my terminal, I have to run the command "/bin/bash --login" before I can run rails/rake related commands. If I don't, I get an error saying "the program "rails" can be found in the following packages: ..."
Any advice?
By default some servers do not allow this due to permissions reason. You can place this in
~/.bashrc and it will automatically work when you open a new terminal
As per bash man page.
When an interactive shell that is not a login shell is started, bash
reads and executes commands from ~/.bashrc, if that file exists. This
may be inhibited by using the --norc option. The --rcfile file option
will force bash to read and execute commands from file instead of
~/.bashrc.
When bash is started non-interactively, to run a shell script, for
example, it looks for the variable BASH_ENV in the environment,
expands its value if it appears there, and uses the expanded value as
the name of a file to read and execute. Bash behaves as if the
following command were executed:
if [ -n "$BASH_ENV" ]; then . "$BASH_ENV"; fi but the value of the
PATH variable is not used to search for the file name.
The file is just shell commands. It is typically used to change prompts, set environment variables, and define shell procedures. Traditionally, the file .profile is used for this purpose, but bash has so many extensions that it needs its own startup file for users that want to put bashisms in startup files.
Easy solution:
Just open terminal. GO to Edit menu from terminal navigation bar, Select "Profile Preferences", It will open "edit profile pop-up". Select "Title and Command" button and "check Run Command as login shell"
ctrl + alt + t -> Edit -> Profile Preferences -> Title and Command -> Check Run command as login shell
Close the terminal and open again. Next time you don't need to "/bin/bash --login"

Running multiple commands in cmd via psexec

I'm working on creating a single command that will run mulitple things on the command line of another machine. Here is what I'm looking to do.
Use psexec to access remote machine
travel to proper directory and file
execute ant task
exit cmd
run together in one line
I can run the below command from Run to complete what I need accomplished but can't seem to get the format correct for psexec to understand it.
cmd /K cd /d D:\directory & ant & exit
I've tried appling this to the psexec example below:
psexec \\machine cmd /K cd /d D:\directory & ant & exit
When executing this it will activate the command line and travel to D:\directory but won't execute the remaining commands. Adding "" just creates more issues.
Can anyone guide me to the correct format? Or something other than psexec I can use to complete this (free options only)?
Figured it out finally after some more internet searching and trial and error. psexec needs /c to run multiple commands, but that syntax doesn't work with the setup I wrote above. I've gotten the below command to run what I need.
psexec \\machine cmd /c (^d:^ ^& cd directory^ ^& ant^)
I don't need to exit because psexec will exit itself upon completion. You can also use && to require success to continue on to the next command. Found this forum helpful
http://forum.sysinternals.com/psexec_topic318.html
And this for running psexec commands
http://ss64.com/nt/psexec.html
This works:
psexec \ComputerName cmd /c "echo hey1 & echo hey2"
For simple cases I use:
PsExec \\machine <options> CMD /C "command_1 & command_2 & ... & command_N"
For more complex cases, using a batch file with PsExec's -c switch may be more suitable:
The -c switch directs PsExec to copy the specified executable to the remote system for execution and delete the executable from the remote system when the program has finished running.
PsExec \\machine <options> -c PSEXEC_COMMANDS.cmd <arguments>
Since you asked about other options and this has tag configuration managment-- I guess you may be interested in Jenkins (or Hudson). It provide very good way of creating master-slave mechanism which may help in simplifying the build process.
I always use like this way :) and works properly
psexec \\COMPUTER -e cmd /c (COMMAND1 ^& COMMAND2 ^& COMMAND3)

Resources