0

I configured cygwin in Windows Server 2008, now we need to implement automation I am writing a batch script to add user to cygwin\etc\passwd file using following command

mkpasswd -l -u %username% -p /home >> /etc/passwd

Please help me how to execute following cmd in batch file

echo off
C:
chdir C:\cygwin\bin

bash --login -i 

mkpasswd -l -u %username% -p /home >> /etc/passwd

It's not working

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
venkat
  • 1
  • 1

1 Answers1

0

You're mixing Windows and Unix in your windows batch file. The batch file is running as a Windows command, as is the mkpasswd command in it. Windows has no concept of /etc/passwd and will throw an error. Probably something like;

D:\cygwin\bin>mkpasswd -l -u testusr -p /home >> /etc/passwd
The system cannot find the path specified.

Given what you want to do with mkpasswd I'd suggest you find a way to run your automation from within Cygwin. Perhaps setting up a cron job.

Community
  • 1
  • 1
AlG
  • 14,697
  • 4
  • 41
  • 54