{"id":2871,"date":"2011-02-15T00:30:36","date_gmt":"2011-02-14T19:00:36","guid":{"rendered":"https:\/\/tothenewco.pro\/blog\/?p=2871"},"modified":"2016-12-19T15:22:42","modified_gmt":"2016-12-19T09:52:42","slug":"using-groovy-execute-bash-scripts","status":"publish","type":"post","link":"https:\/\/tothenewco.pro\/blog\/using-groovy-execute-bash-scripts\/","title":{"rendered":"Using Groovy execute bash scripts"},"content":{"rendered":"<p>Hi Friends,<\/p>\n<p>Recently I had to execute bash script using groovy on a windows server. Though I could easily make the similar script run on linux, but on windows it just didn&#8217;t work as it was unable to recognize the internal DOS commands like cp, rm etc.<\/p>\n<p>On linux the following code worked but not on windows:<\/p>\n<p>[bash]<br \/>\n File script = new File(&#8216;&lt;My_Script_Path&gt;&#8217;)<br \/>\n script.getText().execute()<br \/>\n [\/bash]<\/p>\n<p>So after trying few options, I found that we can call execute method on script path also apart from calling it directly on commands and which worked for both windows and linux, as given below :<\/p>\n<p>[bash]<br \/>\n  &quot;&lt;My_Script_Path&gt;&quot;.execute()<br \/>\n[\/bash]<\/p>\n<p>To see the output of the script on the console, we can use the following command :<\/p>\n<p>[bash]<br \/>\n println &quot;&lt;My_Script_Path&gt;&quot;.execute().text<br \/>\n[\/bash]<\/p>\n<p>Hope this helped!<\/p>\n<p>Cheers!<br \/>\n~~Amit Jain~~<br \/>\namit@intelligrape.com<\/p>\n<blockquote class=\"wp-embedded-content\" data-secret=\"cHmD7sdM4t\"><p><a href=\"https:\/\/tothenewco.pro\/blog\/\">Home<\/a><\/p><\/blockquote>\n<p><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; visibility: hidden;\" title=\"\u201cHome\u201d \u2014 TO THE NEW Blog\" src=\"https:\/\/tothenewco.pro\/blog\/embed\/#?secret=b6ACMt0thF#?secret=cHmD7sdM4t\" data-secret=\"cHmD7sdM4t\" width=\"600\" height=\"338\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hi Friends, Recently I had to execute bash script using groovy on a windows server. Though I could easily make the similar script run on linux, but on windows it just didn&#8217;t work as it was unable to recognize the internal DOS commands like cp, rm etc. On linux the following code worked but not [&hellip;]<\/p>\n","protected":false},"author":7,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":161,"footnotes":""},"categories":[7],"tags":[519,520,9,472],"class_list":["post-2871","post","type-post","status-publish","format-standard","hentry","category-grails","tag-bash-script","tag-execute","tag-groovy","tag-windows"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.0.1 - aioseo.com -->\n\t<meta name=\"description\" content=\"Hi Friends, Recently I had to execute bash script using groovy on a windows server. Though I could easily make the similar script run on linux, but on windows it just didn&#039;t work as it was unable to recognize the internal DOS commands like cp, rm etc. On linux the following code worked but not\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Amit Jain\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/tothenewco.pro\/blog\/using-groovy-execute-bash-scripts\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.0.1\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"TO THE NEW BLOG\" \/>\n\t\t<meta property=\"og:type\" content=\"blog\" \/>\n\t\t<meta property=\"og:title\" content=\"Using Groovy execute bash scripts | TO THE NEW Blog\" \/>\n\t\t<meta property=\"og:description\" content=\"Hi Friends, Recently I had to execute bash script using groovy on a windows server. Though I could easily make the similar script run on linux, but on windows it just didn&#039;t work as it was unable to recognize the internal DOS commands like cp, rm etc. On linux the following code worked but not\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/tothenewco.pro\/blog\/using-groovy-execute-bash-scripts\/\" \/>\n\t\t<meta property=\"og:image\" content=\"https:\/\/tothenewco.pro\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png\" \/>\n\t\t<meta property=\"og:image:secure_url\" content=\"https:\/\/tothenewco.pro\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary\" \/>\n\t\t<meta name=\"twitter:site\" content=\"@tothenew\" \/>\n\t\t<meta name=\"twitter:title\" content=\"Using Groovy execute bash scripts | TO THE NEW Blog\" \/>\n\t\t<meta name=\"twitter:description\" content=\"Hi Friends, Recently I had to execute bash script using groovy on a windows server. Though I could easily make the similar script run on linux, but on windows it just didn&#039;t work as it was unable to recognize the internal DOS commands like cp, rm etc. On linux the following code worked but not\" \/>\n\t\t<meta name=\"twitter:image\" content=\"https:\/\/tothenewco.pro\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/using-groovy-execute-bash-scripts\\\/#article\",\"name\":\"Using Groovy execute bash scripts | TO THE NEW Blog\",\"headline\":\"Using Groovy execute bash scripts\",\"author\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/amit\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#organization\"},\"datePublished\":\"2011-02-15T00:30:36+05:30\",\"dateModified\":\"2016-12-19T15:22:42+05:30\",\"inLanguage\":\"en-US\",\"commentCount\":1,\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/using-groovy-execute-bash-scripts\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/using-groovy-execute-bash-scripts\\\/#webpage\"},\"articleSection\":\"Grails, bash script, execute, Groovy, windows\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/using-groovy-execute-bash-scripts\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.tothenew.com\\\/blog\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/grails\\\/#listItem\",\"name\":\"Grails\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/grails\\\/#listItem\",\"position\":2,\"name\":\"Grails\",\"item\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/grails\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/using-groovy-execute-bash-scripts\\\/#listItem\",\"name\":\"Using Groovy execute bash scripts\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/using-groovy-execute-bash-scripts\\\/#listItem\",\"position\":3,\"name\":\"Using Groovy execute bash scripts\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/grails\\\/#listItem\",\"name\":\"Grails\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#organization\",\"name\":\"TO THE NEW Blog\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/amit\\\/#author\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/amit\\\/\",\"name\":\"Amit Jain\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/using-groovy-execute-bash-scripts\\\/#authorImage\",\"url\":\"https:\\\/\\\/newersworld-sf-static.tothenew.net\\\/prod\\\/profilePicFolder\\\/1cbbcbd3-718c-4d6d-829c-4e225ae91a1a_amit.jain@tothenew.com.jpg\",\"width\":96,\"height\":96,\"caption\":\"Amit Jain\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/using-groovy-execute-bash-scripts\\\/#webpage\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/using-groovy-execute-bash-scripts\\\/\",\"name\":\"Using Groovy execute bash scripts | TO THE NEW Blog\",\"description\":\"Hi Friends, Recently I had to execute bash script using groovy on a windows server. Though I could easily make the similar script run on linux, but on windows it just didn't work as it was unable to recognize the internal DOS commands like cp, rm etc. On linux the following code worked but not\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/using-groovy-execute-bash-scripts\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/amit\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/amit\\\/#author\"},\"datePublished\":\"2011-02-15T00:30:36+05:30\",\"dateModified\":\"2016-12-19T15:22:42+05:30\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/\",\"name\":\"TO THE NEW Blog\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Using Groovy execute bash scripts | TO THE NEW Blog","description":"Hi Friends, Recently I had to execute bash script using groovy on a windows server. Though I could easily make the similar script run on linux, but on windows it just didn't work as it was unable to recognize the internal DOS commands like cp, rm etc. On linux the following code worked but not","canonical_url":"https:\/\/tothenewco.pro\/blog\/using-groovy-execute-bash-scripts\/","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/tothenewco.pro\/blog\/using-groovy-execute-bash-scripts\/#article","name":"Using Groovy execute bash scripts | TO THE NEW Blog","headline":"Using Groovy execute bash scripts","author":{"@id":"https:\/\/tothenewco.pro\/blog\/author\/amit\/#author"},"publisher":{"@id":"https:\/\/tothenewco.pro\/blog\/#organization"},"datePublished":"2011-02-15T00:30:36+05:30","dateModified":"2016-12-19T15:22:42+05:30","inLanguage":"en-US","commentCount":1,"mainEntityOfPage":{"@id":"https:\/\/tothenewco.pro\/blog\/using-groovy-execute-bash-scripts\/#webpage"},"isPartOf":{"@id":"https:\/\/tothenewco.pro\/blog\/using-groovy-execute-bash-scripts\/#webpage"},"articleSection":"Grails, bash script, execute, Groovy, windows"},{"@type":"BreadcrumbList","@id":"https:\/\/tothenewco.pro\/blog\/using-groovy-execute-bash-scripts\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/tothenewco.pro\/blog#listItem","position":1,"name":"Home","item":"https:\/\/tothenewco.pro\/blog","nextItem":{"@type":"ListItem","@id":"https:\/\/tothenewco.pro\/blog\/category\/grails\/#listItem","name":"Grails"}},{"@type":"ListItem","@id":"https:\/\/tothenewco.pro\/blog\/category\/grails\/#listItem","position":2,"name":"Grails","item":"https:\/\/tothenewco.pro\/blog\/category\/grails\/","nextItem":{"@type":"ListItem","@id":"https:\/\/tothenewco.pro\/blog\/using-groovy-execute-bash-scripts\/#listItem","name":"Using Groovy execute bash scripts"},"previousItem":{"@type":"ListItem","@id":"https:\/\/tothenewco.pro\/blog#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/tothenewco.pro\/blog\/using-groovy-execute-bash-scripts\/#listItem","position":3,"name":"Using Groovy execute bash scripts","previousItem":{"@type":"ListItem","@id":"https:\/\/tothenewco.pro\/blog\/category\/grails\/#listItem","name":"Grails"}}]},{"@type":"Organization","@id":"https:\/\/tothenewco.pro\/blog\/#organization","name":"TO THE NEW Blog","url":"https:\/\/tothenewco.pro\/blog\/"},{"@type":"Person","@id":"https:\/\/tothenewco.pro\/blog\/author\/amit\/#author","url":"https:\/\/tothenewco.pro\/blog\/author\/amit\/","name":"Amit Jain","image":{"@type":"ImageObject","@id":"https:\/\/tothenewco.pro\/blog\/using-groovy-execute-bash-scripts\/#authorImage","url":"https:\/\/newersworld-sf-static.tothenew.net\/prod\/profilePicFolder\/1cbbcbd3-718c-4d6d-829c-4e225ae91a1a_amit.jain@tothenew.com.jpg","width":96,"height":96,"caption":"Amit Jain"}},{"@type":"WebPage","@id":"https:\/\/tothenewco.pro\/blog\/using-groovy-execute-bash-scripts\/#webpage","url":"https:\/\/tothenewco.pro\/blog\/using-groovy-execute-bash-scripts\/","name":"Using Groovy execute bash scripts | TO THE NEW Blog","description":"Hi Friends, Recently I had to execute bash script using groovy on a windows server. Though I could easily make the similar script run on linux, but on windows it just didn't work as it was unable to recognize the internal DOS commands like cp, rm etc. On linux the following code worked but not","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/tothenewco.pro\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/tothenewco.pro\/blog\/using-groovy-execute-bash-scripts\/#breadcrumblist"},"author":{"@id":"https:\/\/tothenewco.pro\/blog\/author\/amit\/#author"},"creator":{"@id":"https:\/\/tothenewco.pro\/blog\/author\/amit\/#author"},"datePublished":"2011-02-15T00:30:36+05:30","dateModified":"2016-12-19T15:22:42+05:30"},{"@type":"WebSite","@id":"https:\/\/tothenewco.pro\/blog\/#website","url":"https:\/\/tothenewco.pro\/blog\/","name":"TO THE NEW Blog","inLanguage":"en-US","publisher":{"@id":"https:\/\/tothenewco.pro\/blog\/#organization"}}]},"og:locale":"en_US","og:site_name":"TO THE NEW BLOG","og:type":"blog","og:title":"Using Groovy execute bash scripts | TO THE NEW Blog","og:description":"Hi Friends, Recently I had to execute bash script using groovy on a windows server. Though I could easily make the similar script run on linux, but on windows it just didn't work as it was unable to recognize the internal DOS commands like cp, rm etc. On linux the following code worked but not","og:url":"https:\/\/tothenewco.pro\/blog\/using-groovy-execute-bash-scripts\/","og:image":"https:\/\/tothenewco.pro\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png","og:image:secure_url":"https:\/\/tothenewco.pro\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png","twitter:card":"summary","twitter:site":"@tothenew","twitter:title":"Using Groovy execute bash scripts | TO THE NEW Blog","twitter:description":"Hi Friends, Recently I had to execute bash script using groovy on a windows server. Though I could easily make the similar script run on linux, but on windows it just didn't work as it was unable to recognize the internal DOS commands like cp, rm etc. On linux the following code worked but not","twitter:image":"https:\/\/tothenewco.pro\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png"},"aioseo_meta_data":{"post_id":"2871","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"Article","isEnabled":true},"graphs":[]},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"limit_modified_date":false,"created":"2021-04-29 15:28:52","updated":"2024-02-29 09:26:53","focus_keyword":null,"additional_keywords":null,"truseo_locale":null,"ai":null,"breadcrumb_settings":null,"seo_analyzer_scan_date":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/tothenewco.pro\/blog\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/tothenewco.pro\/blog\/category\/grails\/\" title=\"Grails\">Grails<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tUsing Groovy execute bash scripts\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/tothenewco.pro\/blog"},{"label":"Grails","link":"https:\/\/tothenewco.pro\/blog\/category\/grails\/"},{"label":"Using Groovy execute bash scripts","link":"https:\/\/tothenewco.pro\/blog\/using-groovy-execute-bash-scripts\/"}],"_links":{"self":[{"href":"https:\/\/tothenewco.pro\/blog\/wp-json\/wp\/v2\/posts\/2871","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tothenewco.pro\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tothenewco.pro\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tothenewco.pro\/blog\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/tothenewco.pro\/blog\/wp-json\/wp\/v2\/comments?post=2871"}],"version-history":[{"count":0,"href":"https:\/\/tothenewco.pro\/blog\/wp-json\/wp\/v2\/posts\/2871\/revisions"}],"wp:attachment":[{"href":"https:\/\/tothenewco.pro\/blog\/wp-json\/wp\/v2\/media?parent=2871"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tothenewco.pro\/blog\/wp-json\/wp\/v2\/categories?post=2871"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tothenewco.pro\/blog\/wp-json\/wp\/v2\/tags?post=2871"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}