How do I access a shared drive in a cygwin bash script?

#!/bin/bash "mirror -R //thevault/Shared/Operations/Marketing/test --only-missing -e ;exit" 

I use lftp to mirror a folder on a shared drive. But it fails with "There is no such file or directory." What is the right way to write this? and How do I avoid a space in the file name. I tried literally everything.

I also tried /cygdrive/s/Operations/Marketing/test . This works while I am logged in and I am running the script. But when the task starts, until I am registered in the log file, I get the same "There is no such file." Error.

+4
source share
2 answers

It seems to work fine when logging out.

 #!/bin/bash lftp ftp://username: password@server.com -e "mirror -R //thevault/Share/folder/folder/folder\ with\ spaces/folder/folder --only-missing -e;exit" 

These were shielded spaces in my path. The reason this did not work is because when I reprinted the path that I lowered the order. // thevault / shared <~~ wrong

 #!/bin/bash "mirror -R //thevault/Shared/folder/folder/test --only-missing -e ;exit" 
+1
source

I don’t think that this is generally cygwin support for UNC paths (i.e. \\server\share ), so you will have to rely on mapping to a network drive and then using /cygdrive/s . To fix the problem with it without working when you are not logged in, you need to call the Windows NET program from your script:

 net use s: \\thevault\Shared password /user:myuser 

Perhaps some security problems may have a password in text form, so another possibility is to ensure that the script is run from a user account that has read permission for this server, and then you can omit the password.

+4
source

All Articles