How to log in over network with CMD via UNC path? - networking

I want to be able to connect to a remote machine through its UNC path in either windows CMD or powershell; I have tried C:\pushd \\MyServer\"User Folders"\localUser\TestFolder but when this executes, I get "Logon failure: unknown user name or bad password"
is "pushd" even the right command to use here? I have files that I want to exchange between the two machines on the same network, can there be permission bits I'm overlooking here?

No, pushd is not the right command. For connecting to a remote share you need the command net use:
net use X: \\SERVER\SHARE /user:DOMAIN\USER
If you're using the same account on both hosts (both a domain account as well as identical local accounts will work) you can omit the /user:DOMAIN\USER part.
Normally you'd connect only to the share, but you can also connect directly to some folder below the share:
net use X: \\SERVER\SHARE\some\subfolder

pushd should work for you, given that you have the required permissions to access the share as the current user.
Source:
If you specify a network path, the pushd command temporarily assigns
the first unused drive letter (starting with Z:) to the specified
network resource. The command then changes the current drive and
directory to the specified directory on the newly assigned drive. If
you use the popd command with command extensions enabled, the popd
command removes the drive-letter assignation created by pushd.
Note that the Powershell pushd alias (really Push-Location) does not map a drive letter, but otherwise works the same, i.e. lets you use the respective share as current directory.
So, yes it looks like you have a permission problem. Try accessing the share using explorer (or net use as #Ansgar Wiechers suggests in his answer, or even a simple dir \\share\...) to cross check.

Related

permission set in UNIX folder are not transmitted correctly to NFS share

we have a NFS share where folder in unix are mounted over a NFS windows server.
even after setting the permission to 775 on unix machine for some folder.
The same does not reflect when files are created in that folder by some java process.
so we have a folder like /nobackup/stream on unix machine mounted on nfs server
permission on unix machine
ls -ald /nobackup/stream
rwxrwxr-x owner group
we have an automation process writing result logs and sub directories to stream folder
for some weird reason the files are getting created with permission
rwxr-xr-x owner group
i.e write access to group is not present.
This is causing our automation to fail when at certain places a process running with group user privilege tries to update the files created with above permission
Initially the suspect was umask
so we set umask to 0002 in the perl process which starts automation
that did not help
Files.mkdir is being used to write the file
here the posix permission is correct ,umask is correct still the new files are not getting created with correct permission
also note that automation runs under cygwin shell if thats causing the trouble
How can I ensure that file permission is always set correctly
The problem is that the automation is running in cygwin. Those files are still written by the Windows NFS client, which has no clue how to interpret the permissions set in cygwin.
You need to set the default permissions in the Windows NFS client. You can do this from the command line with nfsadmin. Something like:
nfsadmin client [ComputerName] fileaccess=664
Source: https://technet.microsoft.com/en-us/library/cc754304(v=ws.11).aspx

How to install tools for everyone to use in unix

I'm a freshman, and I created a server with my roomates in order to practice in maintaining a server.
We installed CentOS7. And I would like to ask how I can install a tool for everyone to use?
More particularly, we want to install Cromwell. But since, they don't have instructions on how to install on Unix, I downloaded Linuxbrew and installed it like this.
The downside is that it's not visible to the other users connected to the servers.
I know this is a noob question, but any response would be appreciated.
A standard unix machine has programs (tools and so on) installed in predefined directories like /bin, /usr/bin, perhaps /usr/local/bin. Which to choose is another matter, probably you want /usr/bin. Also the environ variable PATH plays a role.
Into the chosen directory there should be a file representing the "tool". You can put a copy of the executable file in that directory, and set (or check) its permissions. Execution permission can be granted to all users, or only some, it depends. In other words,
/home/me/.linuxbrew/Cellar/cromwell
is not a good place for a "system" tool or app; you should copy that executable in /usr/bin, set ownership (perhaps to root?) with chown, and set the correct permissions with chmod.
You can make a hard link of your executable into the directory; this saves space, but also means that there is only one copy of the executable. Having two different copies (the "stable" one, and the other one you can fiddle with) can be handy.
After the executable is reachable and executable from the chosen users, maybe it needs some support files. To find them, it can rely on fixed locations, or some environment variable, or some configuration file. But all these things are outside of the scope of the question.
Try this command:
you#machine$ sudo chmod [who][op][permissions] filename
"who" refers to the users that have a particular permission: the user ("u"), the group ("g"), or other users ("o", also known as "world"). "op" determines whether to add ("+"), remove ("-") or explicitly set ("=") the particular permissions. "permissions" are whether the file should be readable ("r"), writable ("w"), or executable ("x"). As an example:
you#machine$ chmod o+x file
will add executable permission for others to file.

CFileFind::FindFile and network paths

I have a dll that opens a file for processing. It attempts to find the file with FindFile() function. I also have a service that calls the dll and here is the problem - when the path to the file is a network path, FindFile() fails to find it but only when called from the service, if I call it directly from my application it finds the file. I'm sure the FindFile() function gets the same parameters in both cases as I write a log file with it. Parameter looks like this:
"\SERVER\SERVER_USERS\USERX\TEST.TXT"
I know this is 6 months after the question, but I figured I'd answer it anyway ... Usually, it is a permissions thing. If the service does not have access to the network folder, then it won't find anything. Many services run as a local system account by default, and that account doesn't have built-in access to network files. So try making sure the service is running as an account that has access to the network folder in question.

Creat .BAT to copy a .mdb from network drive to local C:/

I hope I can get some help with this from someone here on this awesome website.
Im a complete noob when it comes to writing batch scripts and I would really like some help.
My situation..
I currently have a network drive on a PC running Windows Server 2008. The drive letter is I:/
within the I-drive, I have a folder named aaaaeast and within that folder is all of my .mdb's
I would like the .bat to copy a specific .mdb from I:/aaaaeast/ to a XP SP3 machine I have in the other room on startup.
Ive tried
copy \myserver\myshare\myfolder\myfile.txt c:\myfiles
But it fails to find the network path.
I know this is got to be a permission issue. My network doesnt have a domain and all the PC's I map to the I:/ map through the Guest account on the Win 2008 server using (username: Guest with no password)
Can someone please help or point me in the right direction.
Ok, this works for me where I work. There is a mapped drive to the location where the master .mdb is.
That is "i:\" drive.
copy i:\ets\lead\software\paint\leadmain.mdb c:\paint
it copies the .mdb to the "c:\paint" drive on the computer where the client clicked on the .bat file. It has been a while so I can't remember where the .bat file sits. Pretty sure it is on the client's computer.
Open Notepad, add the code above, and save making sure to pick the option "All files" down below. That way you can change the extension to .bat from .txt.
copy \\myserver\myshare\myfolder\myfile.txt c:\myfiles
Note: double-backslash
A UNC path (path to a network resource) requires that the target computer name be preceded by two backslashes. Otherwise, starting with \ means "start at the root of the current drive". (Perhaps this was just a typo in the post—that wouldn't cause an error 53.)
Regarding accounts, Windows doesn't really like no-password accounts. There are times when it won't let authentication succeed for a null password. You might try creating an account (with the same name as the username/password on the XP machine) on the 2008 machine and trying it just to see if the user has access to the share. A simple test of that would be something like "dir \myserver\myshare".
If you didn't want to sync accounts, you could create a third user on the 2008 machine and map the share (from the XP machine) as that user. You can also tell Windows to remember the credentials it used for that mapping if you wanted to (i.e. for convenience, definitely not security).

How can I shell out of an ASP.NET page and execute a git command?

I want my ASP.NET page to shell out and execute git commands. I put the commands in a bat file which works:
REM cd to the git repo folder
cd c:\temp\mygitrepo
"c:\Program Files\Git\Bin\git.exe" show c090dc4b8b1b3512c1b5363c371e21d810d02f54 -- myfile.txt
If I run my .bat file from a cmd prompt, no problem.
If I run it using System.Diagnostics.Process.Start, I get this error:
RUNTIME_PREFIX requested, but prefix computation failed. Using static fallback
The error is coming from this git file: http://github.com/git/git/blob/master/exec_cmd.c
I use exactly the same technique to run svn.exe commands, no problem.
EDIT 1: From the thread here I've learned that msysgit installs some files in a location associated with the current user, me, instead of all users. The IIS web server is running under another user account. I tried copying some of the git files that caught my eye, like .gitconfig, to other users (in Documents and Settings). No luck. So, I have switched my focus to getting IIS to impersonate me when it launches the git command.
Is it actually an error, or is it just notifying you of a fallback? Based on the code linked, it appears that the command should still execute successfully, only using the static PREFIX rather than the RUNTIME_PREFIX.
If the command is indeed failing, you might want to make sure that any required environment variables are available when starting the process from .NET. You might also need to impersonate a different windows identity to run the command with proper permissions (I am assuming that the ASP.NET identity is restricted as much as possible.) The ProcessStartInfo object provides a few ways to configure the process, including the windows identity, the process verb, and environment variables. Make sure you are providing the proper context that your batch file requires before running it.

Resources