Shell 使用 cygwin 控制台动态获取 IPV4 地址并添加到路由 table 的脚本 windows
Shell script to get IPV4 address dynamically and add to route table using cygwin console for windows
我正在编写 shell 脚本,该脚本在 windows 的 cygwin 控制台上运行,我的脚本看起来像这样
#!/usr/bin/bash
cmd /c start /d "C:\cygwin\bin" ipconfig | findstr /R /C:"IPv4 Address"
ipconfig #to print
route add 10.2.139.1 192.168.104.1
但是当我在 cygwin 控制台上执行此脚本时,它显示以下错误,即使我更改为 ipconfig \all 它也不起作用
Error: unrecognized or incomplete command line.
USAGE:
ipconfig [/allcompartments] [/? | /all |
我正在尝试通过执行脚本并添加到路由来动态获取 IP 地址 table
谢谢,
罗希斯
我不知道你为什么用 cygwin 而不是 cmd.exe、你用它做什么以及为什么使用 start
,但是,你只缺少一个选项 /b
:
cmd /c start /d "C:\cygwin\bin" /b ipconfig | findstr /R /C:"IPv4 Address"
和start
冗余如下:
cmd /c ipconfig | findstr /R /C:"IPv4 Address"
/b
只是抑制了新创建的 cmd.exe
背景 window.
我正在编写 shell 脚本,该脚本在 windows 的 cygwin 控制台上运行,我的脚本看起来像这样
#!/usr/bin/bash
cmd /c start /d "C:\cygwin\bin" ipconfig | findstr /R /C:"IPv4 Address"
ipconfig #to print
route add 10.2.139.1 192.168.104.1
但是当我在 cygwin 控制台上执行此脚本时,它显示以下错误,即使我更改为 ipconfig \all 它也不起作用
Error: unrecognized or incomplete command line.
USAGE:
ipconfig [/allcompartments] [/? | /all |
我正在尝试通过执行脚本并添加到路由来动态获取 IP 地址 table
谢谢, 罗希斯
我不知道你为什么用 cygwin 而不是 cmd.exe、你用它做什么以及为什么使用 start
,但是,你只缺少一个选项 /b
:
cmd /c start /d "C:\cygwin\bin" /b ipconfig | findstr /R /C:"IPv4 Address"
和start
冗余如下:
cmd /c ipconfig | findstr /R /C:"IPv4 Address"
/b
只是抑制了新创建的 cmd.exe
背景 window.