{"id":1415,"date":"2018-04-06T14:20:50","date_gmt":"2018-04-06T17:20:50","guid":{"rendered":"https:\/\/www.franklinjr.com\/blog\/?p=1415"},"modified":"2018-04-06T14:20:50","modified_gmt":"2018-04-06T17:20:50","slug":"pegar-parte-da-string-no-prompt-de-comando-do-windows","status":"publish","type":"post","link":"https:\/\/www.franklinjr.com\/blog\/index.php\/2018\/04\/06\/pegar-parte-da-string-no-prompt-de-comando-do-windows\/","title":{"rendered":"Pegar parte da string no prompt de comando do Windows"},"content":{"rendered":"<p>O exemplo \u00e9 para pegar somente o nome da pool de aplicativo do retorno do seguinte comando<\/p>\n<pre lang=\"Bash\">\r\nC:\\>appcmd list apppools \/state:started \/xml | findstr \"APPPOOL.NAME\"\r\n    <APPPOOL APPPOOL.NAME=\"site1\" PipelineMode=\"Integrated\" RuntimeVersion=\"\" state=\"Started\" \/>\r\n    <APPPOOL APPPOOL.NAME=\"site1\" PipelineMode=\"Integrated\" RuntimeVersion=\"\" state=\"Started\" \/>\r\n    <APPPOOL APPPOOL.NAME=\"site1\" PipelineMode=\"Integrated\" RuntimeVersion=\"v4.0\" state=\"Started\" \/>\r\n<\/pre>\n<p>Para pegarmos somente o nome, podemos usar o seguinte<\/p>\n<pre lang=\"Bash\">\r\nC:\\>FOR \/F delims^=^\"^ tokens^=2 %i IN ('appcmd list apppools \/state:started \/xml ^| findstr \"APPPOOL.NAME\"') DO @ECHO %i\r\nsite1\r\nsite2\r\nsite3\r\n<\/pre>\n<p>onde delims \u00e9 o delimitador que ser\u00e1 quebrada a string e tokens \u00e9 o n\u00famero da coluna onde est\u00e1 a string que voc\u00ea quer, no nosso caso \u00e9 a segunda coluna, conforme o primeiro comando deste exemplo, no final n\u00f3s damos um DO para fazer alguma coisa com a sa\u00edda do comando, no nosso caso n\u00f3s s\u00f3 mostramos no prompt, mas poderiamos executar algum comando com base nessa sa\u00edda, por exemplo.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>O exemplo \u00e9 para pegar somente o nome da pool de aplicativo do retorno do seguinte comando C:\\>appcmd list apppools \/state:started \/xml | findstr &#8220;APPPOOL.NAME&#8221; Para pegarmos somente o nome, podemos usar o seguinte C:\\>FOR \/F delims^=^&#8221;^ tokens^=2 %i IN (&#8216;appcmd list apppools \/state:started \/xml ^| findstr &#8220;APPPOOL.NAME&#8221;&#8216;) DO @ECHO %i site1 site2 site3 onde [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[51],"tags":[593,594,572,569,579],"class_list":["post-1415","post","type-post","status-publish","format-standard","hentry","category-windows","tag-appcmd","tag-automatizacao","tag-cmd","tag-iis","tag-windows-server"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.0 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\r\n<title>Pegar parte da string no prompt de comando do Windows - Franklin Jr.<\/title>\r\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\r\n<link rel=\"canonical\" href=\"https:\/\/www.franklinjr.com\/blog\/index.php\/2018\/04\/06\/pegar-parte-da-string-no-prompt-de-comando-do-windows\/\" \/>\r\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.franklinjr.com\\\/blog\\\/index.php\\\/2018\\\/04\\\/06\\\/pegar-parte-da-string-no-prompt-de-comando-do-windows\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"In\u00edcio\",\"item\":\"https:\\\/\\\/www.franklinjr.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Pegar parte da string no prompt de comando do Windows\"}]}]}<\/script>\r\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Pegar parte da string no prompt de comando do Windows - Franklin Jr.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.franklinjr.com\/blog\/index.php\/2018\/04\/06\/pegar-parte-da-string-no-prompt-de-comando-do-windows\/","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"BreadcrumbList","@id":"https:\/\/www.franklinjr.com\/blog\/index.php\/2018\/04\/06\/pegar-parte-da-string-no-prompt-de-comando-do-windows\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"In\u00edcio","item":"https:\/\/www.franklinjr.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Pegar parte da string no prompt de comando do Windows"}]}]}},"_links":{"self":[{"href":"https:\/\/www.franklinjr.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1415","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.franklinjr.com\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.franklinjr.com\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.franklinjr.com\/blog\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.franklinjr.com\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=1415"}],"version-history":[{"count":4,"href":"https:\/\/www.franklinjr.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1415\/revisions"}],"predecessor-version":[{"id":1419,"href":"https:\/\/www.franklinjr.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1415\/revisions\/1419"}],"wp:attachment":[{"href":"https:\/\/www.franklinjr.com\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=1415"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.franklinjr.com\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=1415"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.franklinjr.com\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=1415"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}