{"id":17748548,"url":"https://github.com/hansalemaos/cygsubprocess","last_synced_at":"2026-04-20T09:35:00.538Z","repository":{"id":150827525,"uuid":"622288112","full_name":"hansalemaos/cygsubprocess","owner":"hansalemaos","description":"Executes Cygwin bash scripts/commands in Python, captures and prints the output","archived":false,"fork":false,"pushed_at":"2023-04-04T16:47:45.000Z","size":31,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-10T22:50:55.373Z","etag":null,"topics":["bash","capture","cygwin","execute","python","script","shell","subprocess"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/cygsubprocess/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hansalemaos.png","metadata":{"files":{"readme":"README.MD","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-04-01T17:05:19.000Z","updated_at":"2024-04-20T23:06:17.000Z","dependencies_parsed_at":"2023-05-21T19:45:15.800Z","dependency_job_id":null,"html_url":"https://github.com/hansalemaos/cygsubprocess","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/hansalemaos/cygsubprocess","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hansalemaos%2Fcygsubprocess","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hansalemaos%2Fcygsubprocess/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hansalemaos%2Fcygsubprocess/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hansalemaos%2Fcygsubprocess/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hansalemaos","download_url":"https://codeload.github.com/hansalemaos/cygsubprocess/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hansalemaos%2Fcygsubprocess/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271448404,"owners_count":24761441,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-21T02:00:08.990Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bash","capture","cygwin","execute","python","script","shell","subprocess"],"created_at":"2024-10-26T10:07:38.951Z","updated_at":"2025-10-15T23:20:50.646Z","avatar_url":"https://github.com/hansalemaos.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Executes Cygwin bash scripts/commands in Python, captures and prints the output\n\n## pip install cygsubprocess\n\n### Tested against Windows 10 / Python 3.10 / Anaconda / cygcheck (cygwin) 3.4.6\n\n\n```python\n\nfrom cygsubprocess import Bashsubprocess\n\nba = Bashsubprocess(\n    cygfolder=r'C:\\cygwin',mirrorsite=None,addtopath=True\n) # If cygwin is not installed, it will be installed and added to the PATH\nba.convert_path_cyg2win(\"/cygdrive/c/Users/hansc/Downloads/ClipAngel 2.09\")\n# r'C:\\Users\\hansc\\Downloads\\ClipAngel 2.09'\n\nba.convert_path_win2cyg(path=r\"C:\\Users\\hansc\\Downloads\\ClipAngel 2.09\")\n#  '/cygdrive/c/Users/hansc/Downloads/ClipAngel 2.09'\ncmd1 = ba.execute_capture(\"ls -la\")\nprint(cmd1.stdout_lines[:5])\n\ncmd2 = ba.execute_capture([\"ls -la | grep 'py'\"])\nprint(cmd2.stdout_lines[:5])\n\n\ncmd1 = ba.execute_print_capture(\"ls -la\")\nprint(cmd1.stdout_lines[:5])\n\ncmd2 = ba.execute_print_capture([\"ls -la | grep 'py'\"])\nprint(cmd2.stdout_lines[:5])\n\n# gist download\nscriptexec = r\"\"\"\nslugify(){ echo \"$1\" | iconv -t ascii//TRANSLIT | sed -r s/[^a-zA-Z0-9]+/-/g | sed -r s/^-+\\|-+$//g | tr A-Z a-z; }\ncnt=0; gh gist list --limit 3 | cut -f1,2 | tac | while read id name; do ((cnt++)); gh gist clone $id $cnt-`slugify \"$name\"`; done\n\"\"\"\ncmd4 = ba.execute_print_capture(scriptexec)\nprint(cmd4.stdout_lines)\n\n\nbashscr = \"\"\"\n#!/bin/bash\n# set the STRING variable\nSTRING=\"Hello World!\"\n# print the contents of the variable on screen\necho $STRING\n\"\"\"\nbashtofile = ba.exec_sh_to_file(bashscr, printoutput=False)\nprint(bashtofile.stdout_lines)\n\nbashscr = r\"\"\"\n#!/bin/bash\nsalary=1000\nexpenses=800\n#Check if salary and expenses are equal\nif [ $salary == $expenses ];\nthen\n    echo \"Salary and expenses are equal\"\n#Check if salary and expenses are not equal\nelif [ $salary != $expenses ];\nthen\n    echo \"Salary and expenses are not equal\"\nfi\n\"\"\"\nbashtofile2 = ba.exec_sh_directly(bashscr, printoutput=True)\nprint(bashtofile2.stdout_lines)\n\nscriptfile='c:\\\\bashscripttest.sh'\nwith open(scriptfile,mode='w', encoding='utf-8',newline='\\n') as f:\n    f.write(bashscr)\n\nba.installapt() # install apt  https://raw.githubusercontent.com/transcode-open/apt-cyg/master/apt-cyg\nba.apt_install( package='hunspell-de') # install a package with apt\nba.apt_remove( package='hunspell-de') # remove a package with apt\n\ntest2=ba.exec_sh_url( bashscr=r'https://raw.githubusercontent.com/transcode-open/apt-cyg/master/apt-cyg', printoutput=True)\ntest3=ba.exec_sh_file( bashscr=scriptfile, printoutput=True)\ntest4=ba.exec_sh_to_file( bashscr, printoutput=True)\ntest5=ba.exec_sh_directly( bashscr, printoutput=True)\ntest6=ba.get_list_of_files_no_stat( folder=r'C:\\Python34') # windows and cyg path (escaped and unescaped)\ntest7=ba.get_list_of_files_with_stat( folder=r'C:\\Python34') # windows and cyg path (escaped and unescaped)\n\n....\n\n# b'-rwxr-x---+ 1 Administrators hansc    25749 Mar 31 23:52 trayinfo.py.bak\\n'\n# b'-rwxr-x---+ 1 Administrators hansc      671 Apr  1 09:50 trayinfotest.py\\n'\n# b'-rwxr-x---+ 1 Administrators hansc    25878 Apr  1 09:34 traymenuxxxxxxxxxx.py\\n'\n# b'-rwxr-x---+ 1 Administrators hansc     4329 Apr  1 03:12 tw.py\\n'\n# b'-rwxr-x---+ 1 Administrators hansc     8095 Apr  1 08:48 win10ctypestoastxxxxxxxxxx.py\\n'\n# [b'drwxr-x---+ 1 hansc          hansc        0 Apr  1 13:01 1-pyde-py\\n', b'drwxr-x---+ 1 hansc          hansc        0 Apr  1 13:14 1-stra-py\\n', b'drwxr-x---+ 1 hansc          hansc        0 Apr  1 13:14 10-cygwinco-py\\n', b'drwxr-x---+ 1 hansc          hansc        0 Apr  1 13:01 10-tracealllines-py\\n', b'drwxr-x---+ 1 hansc          hansc        0 Apr  1 13:01 2-stra-py\\n']\n# b\"Cloning into '1-tracealllines-py'...\\n\"\n# b\"Cloning into '2-cygwinco-py'...\\n\"\n# b\"Cloning into '3-cygwinco-py'...\\n\"\n# []\n# [b'Hello World!\\n']\n# b'Salary and expenses are not equal\\n'\n# [b'Salary and expenses are not equal\\n']\n....\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhansalemaos%2Fcygsubprocess","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhansalemaos%2Fcygsubprocess","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhansalemaos%2Fcygsubprocess/lists"}