Running CONEMU from CMD with parameters - conemu

I have such a string
"Port knocking\knock\knock.exe" XXX.XXX.X.XXX 1111 & "Port knocking\knock\knock.exe" XXX.XXX.X.XXX 2222 & "Port knocking\knock\knock.exe" XXX.XXX.X.XXX 3333 & ssh root#XXX.XXX.X.XXX -p 6325 -i "SSH_Keys\private_key-openssh_new" & -new_console:n:P:"^<Solarized Git^>":d:"Port knocking\knock\":t:"ROOT"
I want to run this from the Total Commander button.
If I do it in CMD, everything works, as I need, but this line is too long, and it does not fit in the command field of button TC (as well as in the "Start Menu->Run").
How can I run Conemu with such parameters

Related

batch script having input redirection called from cmd adds numeric arguments automatically

I have a cmd batch script named runcmd.bat as follows
plink.exe -ssh 1.11.1.1 -l kaka -pw babay < commands.txt >output.txt
when this batch script is called from CMD, it generates the following error:
C:\Users\ASAD\Desktop\PuTTY>runCmd.bat
C:\Users\ASAD\Desktop\PuTTY>c:
C:\Users\ASAD\Desktop\PuTTY>cd \
C:\>cd "Users\ASAD\Desktop\PuTTY"
C:\Users\ASAD\Desktop\PuTTY>plink.exe -ssh 1.11.1.1 -l kaka -pw babay 0<commands.txt 1>>output.txt
The system cannot find the file specified.
C:\Users\ASAD\Desktop\PuTTY>
The system cannot find the file specified.
If you can see, it automatically adds 0 and 1 before < and > input and output redirections operators.
I'm using Windows 8.1 x64. I have also tried this same in windows 2012 R2 Server but all ended up showing the same.
I expect that the script executes without adding any number before input and output redirector.

PuTTY command line automate serial commands from file

I am trying to connect to a serial port and send a series of commands from a file.
Firstly I have mananged to connect via the following:
PuTTY.exe -serial COM3 -sercfg 57600,8,n,1,N
E.g. I have a file called commands.txt with a series of serial commands I wished to be sent.
I tried the following however it failed to work:
PuTTY.exe -serial COM3 -sercfg 57600,8,n,1,N -m commands.txt
Any help is greatly appreciated.
Try like this :
for /f "delims=" %%a in ('type commands.txt') do PuTTY.exe -serial COM3 -sercfg 57600,8,n,1,N -m %%a
Another solution which I have used to regularly send commands to a device uses a combination of PuTTY and Autohotkey.
For the initial setup, configure a PuTTY session and save it. In my case I named is Oasis.
The following Autohotkey function can send a command to the already open PuTTY session. If PuTTY is not open it will start the saved session. oasis_putty_name() is the name of the PuTTY window once it's open, it will depend on the COM port selected. location_putty() is the location of the PuTTY executable. Both of these can be hard coded but I wanted to keep the variables separate from the functions.
; Oasis Check --------------------------------------------------
oasis_check(){
putty_name := oasis_putty_name()
; Start PuTTY if it's not already running
IfWinNotExist, %putty_name%
{
putty := location_putty()
Run %putty% -load Oasis
Sleep,1000
}
; Format Time Stamp
FormatTime, TimeString,,yyyy-MM-dd HH-mm-ss
; Record Oasis Values
ControlSend, , %TimeString%{ENTER}, %putty_name%
Sleep, 2000
ControlSend, , all?{ENTER}, %putty_name%
}
The frequency of execution can be controlled with another Autohotkey script or, as in my case, with the Windows Task Manager.

Opentsdb open source time series database

Is there anyone who has installed opentsdb on Ubuntu 15.04 version? If so please share the steps to be followed. I tried number of times but I am not able to install it properly.
You need to write tcollector, for example:
Step 1: create metrics:
./tsdb mkmetric proc.loadavg.1m proc.loadavg.5m
Step 2: create collector in shell script or command line.
cat >loadavg-collector.sh <<\EOF
#!/bin/bash set -e
while true; do
awk -v now=`date +%s` -v host=`hostname` \ '{ print "put proc.loadavg.1m " now " " $1 " host=" host;
print "put proc.loadavg.5m " now " " $2 " host=" host }'
/proc/loadavg sleep 15 done | nc -w 30 host.name.of.tsd PORT EOF
Then:
chmod +x loadavg-collector.sh
nohup ./loadavg-collector.sh &
It will collect data every 15 second on metrics proc.loadavg.1m and proc.loadavg.5m. Now you will be able to see graph in webinterface of opentsdb.
For detail please check the link below:
http://opentsdb.net/docs/build/html/user_guide/quickstart.html

ConEmu commands in task

I'm trying to get a Task in ConEmu to open several consoles, and for each run a batch-like script when opened. For example:
Open a Git Bash, name the console "X", set the current directory to "Y".
Open another Git Bash and run a set of commands, for example "cd A/B/C", "vagrant up"
Open a regular command window, run the command "cd D/E/F", "grunt watch"
I want the second and third consoles to appear alongside each other, but underneath the first console. So far I am stuck getting commands to run; I have a task that runs the following:
"%ProgramFiles(x86)%\Git\bin\sh.exe" --login -i "-cur_console:n:t:Git Bash" "-cur_console:d:C:\Users\Ole Vik\dev"
"%ProgramFiles(x86)%\Git\bin\sh.exe" --login -i "-cur_console:s1TVn:t:Vagrant"
cmd "-cur_console:s2THn:t:Third"
Reading the ConEmu wiki led me to the new_console and cur_console switches, but I'm having trouble figuring out if I can somehow enter commands in the Task setup, or maybe if I can have it run a .bat script on each console.
No colon is needed between switches (n & t for example).
cmd has /k switch to run commands.
I don't know the way to tell bash "run this command and stay in prompt". May be you need to run commands with &. I'm not sure about second line, you need to check it yourself.
"%ProgramFiles(x86)%\Git\bin\sh.exe" --login -i "-cur_console:nt:Git Bash" "-cur_console:d:C:\Users\Ole Vik\dev"
cmd -cur_console:s1TVnt:Vagrant /c vagrant up & "%ProgramFiles(x86)%\Git\bin\sh.exe" --login -i"
cmd -cur_console:s2THnt:Third /k cd /d "D\E\F" & grunt watch

.VBS to run DNSCMD /enumrecords in a for loop on an array of node names. CLI shows as if I ran a DNSCMD /?

I'm trying to run DNSCMD.exe /enumrecords from a .vbs on our Windows Server 2003 DNS server and dump the results into a .csv file for each node name under a DNS Zone.
I have entered the Nodes I want to run the command against under the zone into an array and entered a list of filenames into another array.
The idea being to run a for loop to walk through each node name and file name 0-42 and run the command for each node name and outputting to each filename in sequence.
Option Explicit
Dim ncpArr, NODE, fnameArr, FILE, DNSCMD, objWSHShell, QComm
Set objWSHShell = WScript.CreateObject("WScript.Shell")
ncpArr = Array(42 item array of DNS Nodes)
fnameArr = Array(42 item array of filenames)
QComm = "DnsCmd DNSservername /enumrecords contoso.com " & ncpArr(NODE) & " /Additional> c:\DNSData\" & fnameArr(NODE) & ".csv"
For NODE = 0 to 42
objWSHShell.Run QComm,1,True
'objWshShell.Exec QComm
'wscript.echo "| " & ncpArr(NODE) & " | | " & fnameArr(NODE) & " |"
'wscript.echo DNSCMD
Next
The intent was to save myself some time but if anything I've tripled the time it would have taken to run these 42 commands while writing this script.
What I have figured out so far is:
When I run this command on the DNS server it outputs a CSV exactly like I want it to
DnsCmd dnsservername /enumrecords zone.name node.st.name /Additional /continue> c:\DNSData\state_city_net.csv
When I run the same command like this:
Set objWSHShell = WScript.CreateObject("WScript.Shell")
objWSHShell.run "dnscmd /enumrecords zone.name node.st.name /additional> c:\DNSData\state_city_net.csv"
The command line box pops up briefly showing the instructions for DNSCMD as if I ran a DNSCMD /?. I've only been able to get a look at it by running the loop above and hitting Pause/Break at just the right time. Not sure if it's possible to get the Command Line box to stay open to show any errors
One thing I noticed is normally when you run it with an incorrect syntax it will have some information about the error at the top. In this case it literally looks like the DNSCMD /? instructions with no error at the top.
I'm seriously wondering if it's just not possible to run DNSCMD /enumrecords using a .vbs. as you can see from the commented out parts I've tried a few things to show the syntax is correct. When I Echo the output of the loop I can enter the exact syntax into the command line on the DNS server and it works!
If ANYONE could just peek at what I have above and tell me why when I run my script it does that or if you could even just confirm that my scripting is sound and it's something with DNSCMD it would really help me sleep better.
Thanks
Drew
When you enter
DnsCmd dnsservername /enumrecords zone.name node.st.name /Additional /continue> c:\DNSData\state_city_net.csv
in a shell ('DOS box'), the redirection (>) is provided by this shell. Your
objWSHShell.run "dnscmd /enumrecords zone.name node.st.name /additional> c:\DNSData\state_city_net.csv"
just runs a process and can't do redirection. Change your line to
objWSHShell.run "%comspec% /c dnscmd /enumrecords zone.name node.st.name /additional> c:\DNSData\state_city_net.csv"
and think about the (missing) /continue. For (single) testing, you can change the /c (close when done) to /k (keep open). Probably re-reading about (using?) all three parameters of the .Run method and paying attention to the return value may be a good idea.

Resources