techmiss
asked on
Unix File Move Script
Good afternoon all,
I have a directory on my Unix box. Everyhour I want to move the contents of this directory (1 file) and move it to a share on a windows box - presumably via a unc path.
My questions
1) Will the mv command work to a unc share on windows?
2) can anyone provide a snippet (or whole code) to allow me to do this?
I plan on running the script every hour via a cron job.
Many Thanks
K
I have a directory on my Unix box. Everyhour I want to move the contents of this directory (1 file) and move it to a share on a windows box - presumably via a unc path.
My questions
1) Will the mv command work to a unc share on windows?
2) can anyone provide a snippet (or whole code) to allow me to do this?
I plan on running the script every hour via a cron job.
Many Thanks
K
You can do this using a unix ftp client but your windows box should have an active ftp server.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If you use Samba to mount the file system you could use mv
http://articles.techrepublic.com.com/5100-10878_11-5080709.html
http://articles.techrepublic.com.com/5100-10878_11-5080709.html
ASKER
Thanks I'm getting there.
Martin - with reference to that link do I actually put the mount command in the smb.conf file?
Cheers
K
Martin - with reference to that link do I actually put the mount command in the smb.conf file?
Cheers
K
smb.conf is for the Samba Server and is really only necessary if you want to share directories from Linux to Windows.
When mounting the shared windows directory you either put the mount command in one of your startup-scripts or you can put the necessary information in "/etc/fstab".
When mounting the shared windows directory you either put the mount command in one of your startup-scripts or you can put the necessary information in "/etc/fstab".
You may wish to use the smbmount utility. I have attached the help screen.
[root@linux]# smbmount
Usage: mount.smbfs service mountpoint [-o options,...]
Version 3.0.10-1.4E.12.2
Options:
username=<arg> SMB username
password=<arg> SMB password
credentials=<filename> file with username/password
krb use kerberos (active directory)
netbiosname=<arg> source NetBIOS name
uid=<arg> mount uid or username
gid=<arg> mount gid or groupname
port=<arg> remote SMB port number
fmask=<arg> file umask
dmask=<arg> directory umask
debug=<arg> debug level
ip=<arg> destination host or IP address
workgroup=<arg> workgroup on destination
sockopt=<arg> TCP socket options
scope=<arg> NetBIOS scope
iocharset=<arg> Linux charset (iso8859-1, utf8)
codepage=<arg> server codepage (cp850)
unicode use unicode when communicating with server
lfs large file system support
ttl=<arg> dircache time to live
guest don't prompt for a password
ro mount read-only
rw mount read-write
This command is designed to be run from within /bin/mount by giving
the option '-t smbfs'. For example:
mount -t smbfs -o username=tridge,password=foobar //fjall/test /data/test
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I have use the command above but I get error 13 - permission denied, the share I am trying to connect to is not locked down to a level that should trigger this message.
After researching the problem on another Linux forum the concensus was that the domain had to be present in the command e.g.
mount -t cifs //Winserver/share -o username=domain/Winusernam e,password =password /mnt
but this won't work either as I am getting the help screen presumably because my syntax is incorrect.
Confused!
Thanks
K
After researching the problem on another Linux forum the concensus was that the domain had to be present in the command e.g.
mount -t cifs //Winserver/share -o username=domain/Winusernam
but this won't work either as I am getting the help screen presumably because my syntax is incorrect.
Confused!
Thanks
K
There needs to be a backslash rather than a slash between the domain and user. In your example it would be:
mount -t cifs //Winserver/share -o username=domain\\Winuserna me,passwor d=password /mnt
You *can* type the above in manually, but it might be better in /etc/fstab, so that it happens automatically. The trouble is that /etc/fstab is world-readable, so anyone can see your sensitive login information. To avoid this, I would use a credentials file. The manual mount line becomes:
mount -t cifs //Winserver/share -o credentials=/etc/cred /mnt
or, in /etc/fstab
//Winserver/share /mnt cifs credentials=/etc/cred 0 0
and /etc/cred contains:
username=workdom\simon
password=HelloMum
You can then assign tight permisions to /etc/cred so that only root can read it.
Simon
mount -t cifs //Winserver/share -o username=domain\\Winuserna
You *can* type the above in manually, but it might be better in /etc/fstab, so that it happens automatically. The trouble is that /etc/fstab is world-readable, so anyone can see your sensitive login information. To avoid this, I would use a credentials file. The manual mount line becomes:
mount -t cifs //Winserver/share -o credentials=/etc/cred /mnt
or, in /etc/fstab
//Winserver/share /mnt cifs credentials=/etc/cred 0 0
and /etc/cred contains:
username=workdom\simon
password=HelloMum
You can then assign tight permisions to /etc/cred so that only root can read it.
Simon
Or you can create a normal local user at the Windows server itself & use it with mount -t cifs command.
ASKER
Thanks for your replies, I will use the creds file when I have resloved the original problem (it's my first attempt)
I need to be sure I am using the correct syntax, as below
mount -t cifs //10.41.5.242/warehouse -o username=f1\\warehouse,pas sword=P4$$ w0rd /mnt
as I am getting error:
mount error 13 = Permission denied
Refer to the mount.cifs(8) manual page (e.g.man mount.cifs)
I have removed all the permissions to this share to a level that should not trigger this message (hence my asking if my command is 100%)
Cheers
K
I need to be sure I am using the correct syntax, as below
mount -t cifs //10.41.5.242/warehouse -o username=f1\\warehouse,pas
as I am getting error:
mount error 13 = Permission denied
Refer to the mount.cifs(8) manual page (e.g.man mount.cifs)
I have removed all the permissions to this share to a level that should not trigger this message (hence my asking if my command is 100%)
Cheers
K
I see you have this in the Win95/98 Zone - if the windows box is indeed one of those, that might be the problem. I have had great difficulty getting UNIX to mount from Win98 machines, and in getting Win98 machines to mount UNIX shares. Do you have an XP or Vista machine that you could try this on?
ASKER
Hi,
I have tried XP too and get the same message "Permission Denied" I'm going to try it on a Wiin Server 2003 R2 box and see if that works.
Also - my kernel version is 2.6.9-42.ELsmp, does anyone know if this supports cifs?
Thanks
K
I have tried XP too and get the same message "Permission Denied" I'm going to try it on a Wiin Server 2003 R2 box and see if that works.
Also - my kernel version is 2.6.9-42.ELsmp, does anyone know if this supports cifs?
Thanks
K
That kernel certainly does support cifs - I've just mounted a Samba-shared disk on such a box (though I didn't have to enter a domain).
What is the output of "smbclient -L //10.41.5.242"
What is the output of "smbclient -L //10.41.5.242"
ASKER
Output is:
[root@SVUKQAD1 /]# smbclient -L //10.41.5.242
params.c:Parameter() - Ignoring badly formed line in configuration file: create mask 777
params.c:Parameter() - Ignoring badly formed line in configuration file: create mask 777
params.c:Parameter() - Ignoring badly formed line in configuration file: create mask 777
params.c:Parameter() - Ignoring badly formed line in configuration file: create mask 777
params.c:Parameter() - Ignoring badly formed line in configuration file: create mask 777
params.c:Parameter() - Ignoring badly formed line in configuration file: create mask 777
params.c:Parameter() - Ignoring badly formed line in configuration file: create mask 777
params.c:Parameter() - Ignoring badly formed line in configuration file: create mask 777
params.c:Parameter() - Ignoring badly formed line in configuration file: create mask 777
Password:
What password does it require??
Cheers
K
[root@SVUKQAD1 /]# smbclient -L //10.41.5.242
params.c:Parameter() - Ignoring badly formed line in configuration file: create mask 777
params.c:Parameter() - Ignoring badly formed line in configuration file: create mask 777
params.c:Parameter() - Ignoring badly formed line in configuration file: create mask 777
params.c:Parameter() - Ignoring badly formed line in configuration file: create mask 777
params.c:Parameter() - Ignoring badly formed line in configuration file: create mask 777
params.c:Parameter() - Ignoring badly formed line in configuration file: create mask 777
params.c:Parameter() - Ignoring badly formed line in configuration file: create mask 777
params.c:Parameter() - Ignoring badly formed line in configuration file: create mask 777
params.c:Parameter() - Ignoring badly formed line in configuration file: create mask 777
Password:
What password does it require??
Cheers
K
ASKER
Ah i've done it again with a blank password:
Anonymous login successful
Domain=[F1] OS=[Windows 5.1] Server=[Windows 2000 LAN Manager]
Sharename Type Comment
--------- ---- -------
Error returning browse list: NT_STATUS_ACCESS_DENIED
session request to 10.41.5.242 failed (Called name not present)
session request to 10 failed (Called name not present)
Anonymous login successful
Domain=[F1] OS=[Windows 5.1] Server=[Windows 2000 LAN Manager]
Server Comment
--------- -------
Workgroup Master
--------- -------
Anonymous login successful
Domain=[F1] OS=[Windows 5.1] Server=[Windows 2000 LAN Manager]
Sharename Type Comment
--------- ---- -------
Error returning browse list: NT_STATUS_ACCESS_DENIED
session request to 10.41.5.242 failed (Called name not present)
session request to 10 failed (Called name not present)
Anonymous login successful
Domain=[F1] OS=[Windows 5.1] Server=[Windows 2000 LAN Manager]
Server Comment
--------- -------
Workgroup Master
--------- -------
ASKER
The main problem with this was that my password had $$ in it, Linux did not like this, when I changed password to an easier one it connected.
Thanks for all your help.
K
Thanks for all your help.
K
ASKER
Unrelated password complexity was (seems) to be the root cause so I have distributed points to experts who were most helpful.
Thanks
Thanks