Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 385 Vote(s) - 3.53 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Run/invoke windows batch script from sh or bash script

#1
I have a sh/bash script that needs to call a batch file with parameters (parameters are file names and are given in DOS/Windows format).

Basically I have:
**script.sh**

#!/bin/sh
declare var1=$1
declare var2=$2
dosomething var1 var2
...
<invoke batch script> var1 var2
...
dosomethingelse

I'm using `GNU bash, version 3.1.0(3)-release (i686-pc-msys)` as the shell, on `msysgit`

The problem is that when i run from script:
`$COMSPEC /c batchfile param1 param2`
either I get an "empty prompt" which looks like bash, but no command result is displayed on the console, either `cmd.exe` start, but doesn't execute the script.

I've tried quoting the params to bash like this:

$COMSPEC /c \"batchfile param1 param2\"
$COMSPEC /c \"\"batchfile param1 param2\"\"
$COMSPEC /c \"\"batchfile \"param1\" \"param2\"\"\"

But I didn't get any result.
Reply

#2
It seems that I needed to escape the space from the cmd param:

$COMSPEC \/c batch-file\ \"$var1\"\ \"$var2\"
or

$COMSPEC /c batch-file\ \"$var1\"\ \"$var2\"

I'm not sure whether the / from /c needs to be escaped, but it works fine both ways escaped.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through