I have an Ubuntu 10.04 server running Samba.
I want to write a script (for Linux or Windows computer) that, given the IP of this server and the path of the shared Samba folder, can automatically create a "network drive" icon on the desktop. Both machines are on a local network.
I realize this will be different for linux/windows.
Any suggestions? I'm just not sure where to start. Thanks!
For Windows machines, you want to look at net use. For instance, to map the share "Data" on 192.168.0.2 to Z:, you'd write net use Z: \\192.168.0.2\Data. There is a lot of options, so check net help use for a complete list. For instance, you might want to look at /persistent, which would automatically recreate the share every time you log in.
Or you could put this in a .BAT file which is executed when logging in.
On linux, I think you'd generally have to be root to do this, as it'd require a mount command. I know some desktop environments (such as GNOME) get around this, but to acually mount it you need root. The command to mount the same share at the mountpoint /mnt/Data would simply be mount //192.168.0.2/Data /mnt/Data, if you allow anyone access. If you require a logon, you need to add -o User=YOURUSER. You will then be prompted for a password.
(Note that this requires the CIFS/SMB drivers to work)
Related
I am using Parallels in order to be able to use the same code across multiple platforms without needing any kind of sync mechanism.
This worked really well but there is one serious downside, the mounted folder is owned by root and this is forcing me to use root account on the VM.
This is clearly not a good security practice and also prevents me from discovering bugs that would be visible only when running as a normal user.
How can I address this problem? I was not able to find any options in Parallels for choosing the username.
I was able to solve the problem using this approach:
Cat /etc/mtab and copy the line from there to /etc/fstab and adding uid=xxx,gid=xxx.
Also change the /media/psf/Home with /home/xxx
Doing a mount -a and after this you do share share same home account for your user.
Be sure that you can login as root on the VM because if you make a mistake you don't want to end-up lockedout of your machine.
I have an issue with mounting Windows file share in Cygwin.
We have Windows file share which is using NFS to share content. I was assigned to install Cygwin on it so some application can connect over SFTP to that server.
Now they need to access the shared folder from that application and the app would pull data from that folder.The thing is that the folder is Windows shared folder (exmple; \server\photos). the current Windows users need to be able to connect to that share (it is mapped to their M drive) and the app need to connect to SFTP and pull the data from there.
My idea was to mount that NFS share in Cygwin and set it as /home directory so when the app connects, it automatically goes there.
My questions are: is this possible, and does anyone know any better solutions?
I am open for all suggestions.
Thank you.
Cygwin views the top of its directory tree / to be within the Windows directory C:\cygwin64 (or whatever its installation directory was). As a result, you are unable to move above that point in the filesystem from a Cygwin shell. The solution is to go through Cygwin's directory /cygdrive, which is automatically set up as the access point where all Windows disk drives are mounted. If your shared folder is mounted in Windows as M:, you should be able to access it in Cygwin as /cygdrive/m without any additional work.
As far as setting it up as /home, you might be able to create a symbolic link from /home to /cygdrive/m if that is what you need.
I'm currently developing apps for the inPulse watch (if you're a geek, check out www.GetInPulse.com) and am compiling for the watch while on a Mac. But deploying the app to the device takes several minutes. They do however offer a simulator, but that only runs under Linux so I installed Ubuntu in a VM, which works great.
What I'm hoping is to stay completely on the Mac side, except be able to execute a build step or shell script that can 'call into' the VM and launch a shell script there which kicks up the simulator. That way I can just add 'sim' as a step in my makefile back on the 'mac' side.
Currently, I'm mousing back and forth too damn much and I have terminals open all over the place in both the host and the guest OSes. Just trying to clean that up and cross-machine scripting seems like it would work in theory. Just don't know if the boundaries of cross-machines are even a valid thing.
The host OS doesn't know what a “shell” is inside the guest. A shell is an OS-dependent concept, and while the host OS technically knows everything that's going on in the guest, its only contact is by observing the guest memory and the instructions it runs, altogether the wrong level of abstraction here.
The most natural way to run shell commands from one OS to another is to use a remote shell facility over a network link; in practice, that means SSH. You need a network link between the two machines, and once you have that, it doesn't matter that one is a VM running inside the other. There probably is a network link already between the two machines; in case there isn't, make sure you activate a bridged network or a host-only network or whatever your VM technology offers.
Install an SSH client on the host (there's probably one already) and an SSH server on the guest (openssh-server Install openssh-server http://bit.ly/software-small). Then set up public-key authentication between the two machines so you don't need to type a password all the time.
You'll get shell access on the guest. If you need to manipulate GUI applications, you'll need to work a little more than that. ssh DISPLAY variable may help, or perhaps How can I run Firefox on Linux headlessly (i.e. without requiring libgtk-x11-2.0.so.0)?.
The description is quite long. Please spend some time to read it. ^:)^
I have an old PHP application and I'm trying to test and debug it. Unfortunately, the application uses important data so I can't just click this and that. Now, what I'm trying to do is create a copy of the application in a different computer. From now on, I will call the computer running my original PHP application as 'Computer A' and the computer which I'm going to use to run the copy of the application as 'Computer B'.
To prevent missing link problems since the application contains static paths, such in images or tags, I have to copy all files and folder related to my PHP application from Computer A to the same path in Computer B. Unfortunately, Computer B only has drive C while Computer A has drive D and the files of my PHP application is located in 'D:\xampp\htdocs' in Computer A.
OK, now I have to create drive D in computer B. At first, I tried to create a second partition in Computer B by using PowerQuest Partition Magic 8, but somehow Partition Magic doesn't run in Computer B. I have tried to reinstall it but it still doesn't run. So, another alternative is to create a virtual drive. That is what I did. I created a virtual drive by running the 'subst' command in Command Prompt. The virtual drive is D and it refers to a directory, which is 'C:\Virtual'.
After I have drive D in Computer B, I installed XAMPP there. The installation was successful. Now, I also have 'D:\xampp\htdocs' in Computer B. However, when I ran the Apache, MySQL, or Filezilla service, I receive an error message "Error 3: The system cannot find the file specified.". In Computer B, there is no IIS or process using the port 80. What should I do? Please help me.
Many thanks in advance,
Haris
I hope this doesn't constitute cross-posting, here goes...
Subst doesn't instantiate a mount globally, or within the System User / NT Authority, so the server (apache) cannot access it. Apache accesses via the system account, and so it cannot see a subst mount point (so-called).
Following from this: http://msdn.microsoft.com/en-us/library/aa363908%28v=VS.85%29.aspx
...it seems you can instantiate a subst globally via either the win api or possibly directly in the registry using the DefineDosDevice function or method.
Any way you try to do a subst, even using something such as RunAsSystem to attempt to apply the subst command within the system-user context, will fail to produce a viable result.
However, I found that by creating the DosDevice in the registry I have a viable 'subst' mount that apache/mysql/php-win can use. You can also find ways of doing it via wmi, vb, c+, etc, and I do not know if (I doubt) the registry method is directly the same, but here it is...
Example, I want: subst S: C:\PortableUSB
asA.reg file...
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\DOS Devices]
"S:"="\\??\\C:\\PortableUSB"
Or, in the registry it will look like this (so you can manually add it this way)...
A String Name of "S:" (without the quotes. Use your preferred DriveLetter, of course)
This String's Value is "\??\C:\PortableUSB" (without the quotes. Use your own path, of course)
Requires a restart. The subst is persistent and available globally. I do not yet know how reliable it is, but I am using it with success so far.
TwoHawks
I have a D-Link DNS-323 NAS, running some sort of Linux as its OS.
I map a volume as a share in Windows Vista (Ultimate SP2). There are some directories and files on that share that I cannot change/delete - no matter what I try. Trying all of Windows security/permissions dialogs don't work, as the files owner is "Unix/root" and all other Windows users have read-only permissions.
I managed to ssh into the OS and verified that these files belong to 'root' - the user under which I log in, and all the other files (the ones I can change) belong to 'nobody'.
All fine and well, while I'm in ssh, I can always "chmod +w" the files, or "chown nobody". But my question is this: how can I make my Windows user (let's call him 'admin') impersonate 'root' on the Linux, so I can simply manipulate files from Windows, without resorting to ssh?
In other words, and to make the whole question plainer: how do you tell your OS that a certain user on Windows is a certain user on linux? (that way, I can have 'admin' be 'root').
Thanks in advance,
Guy
Samba can do something like you've said. it basically emulates windows compatible permissions on a linux box..
Assuming the NAS is running samba (almost certainly), there should be a samba config file somewhere in /etc. But I don't know if it would be editable.
The remapping between windows/Linux and permissions is all done on the server (samba) side.
There are a lot of Samba faqs about this.
Cygwin can do that.
EDIT:
The cacls command in Windows looks like it does what you want.