Cygwin missing sudo

0

I am trying to run a linux script on my Windows machine using cygwin.

I have already read and tried the solutions from There's no 'sudo' command in Cygwin, without any success.

I have a script that uses sudo in the regular linux environment. but when I run the scirpt on cygwin, it throws this error message:

project_common.sh: line 604: sudo: command not found

I know cygwin does not have sudo, and the referenced question mentioned earlier said to use:

>#!/usr/bin/bash
>"$@"

I tried executing that command before running the script. and also embedding the command into the script. Neither one help. So not sure what am I missing.

Churk

Posted 2012-06-04T13:17:51.157

Reputation: 101

Answers

4

Remove any sudo's in the file and run the script as Administrator.

That being said, the Linux idea of root and Windows idea of Administrator do not correspond exactly. You may still have permission issues that need to be rectified manually or by modifying the script further, especially on Windows Vista/7.

By the way, the referenced question wanted you to put

>#!/usr/bin/bash
>"$@"

in a file named sudo, give it executable permission with chmod, and then put it in some directory in your $PATH, such as /sbin. The resulting file will not do anything except execute the paramaters you give it as a command. The idea was to make a "fake" sudo that does nothing. You can also just delete the sudo's from the file.

LawrenceC

Posted 2012-06-04T13:17:51.157

Reputation: 63 487

Thats not really the right answer. It is almost like saying, there is no copy command in Microsoft Office, Let rewrite MS Office. – Churk – 2012-06-04T14:08:29.427

1No, it's like saying given operating system A and B, and capability C which works one way under A and a different way under B, that your script which can be run under A and B might need to be rewritten to account for the differences in implementation of C. – LawrenceC – 2012-06-04T14:14:22.180

1sudo isn't in cygwin because you essentially are the superuser of the shell when you "Run [cygwin] as Administrator". In other words, your problem is not with cygwin, it's with your file permissions in Windows. – kevlar1818 – 2012-06-04T14:45:32.297

0

There are other answers on Stackoverflow and Superuser which shows how to execute a command with elevated priviliges from a Cygwin prompt. I'm using an alias:

alias sudo="cygstart --action=runas"

Works as a charm for external programs (not shell built-ins, though):

sudo chown User:Group <file>

thoni56

Posted 2012-06-04T13:17:51.157

Reputation: 163

0

Try this:

#!/usr/bin/env bash

cygstart --action=runas "$@"

It works similar to sudo, the disadvantage is, that you need to confirm the UAC dialog manually. This script is part of my dot repo.

elsamuko

Posted 2012-06-04T13:17:51.157

Reputation: 81