LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 09-13-2006, 02:30 PM   #1
achtung_linux
Member
 
Registered: May 2006
Posts: 50

Rep: Reputation: 15
Automate Samba logon with a bash script?


Hi,
I am trying to write a script that will fetch a file from a Windows machine and execute it on Linux. Since I am using Samba for all the Linux-Windows file traffic, I am always confronted with the "password: " prompt when trying to script my way in the Windows shared folders. How to script the login part of Samba so that file fetching is automated?
P.S. Maybe this topic is not networking per se, maybe more like "Linux programming" so I apologize to moderators for possible abuse...
 
Old 09-13-2006, 05:22 PM   #2
achtung_linux
Member
 
Registered: May 2006
Posts: 50

Original Poster
Rep: Reputation: 15
OK, I've got out of the "password: " loop by using the -n handle, that way Samba isn't asking for password. But now all it does is just... sitting there accepting no commands.
How to get the script to keep on passing commands to Samba once the connection is open
 
Old 10-16-2006, 09:07 AM   #3
changlinn
LQ Newbie
 
Registered: Jan 2005
Location: Australia
Distribution: ParrotOS, Kali, Ubunut
Posts: 28

Rep: Reputation: 15
I have spent the last couple of days looking for a solution to this as well, can you pot what you have already and I will try and help, at the moment, I am testing .bashrc and crontab to trying and get this working.
 
Old 10-18-2006, 04:26 PM   #4
andrewdodsworth
Member
 
Registered: Oct 2003
Location: United Kingdom
Distribution: SuSE 10.0 - 11.4
Posts: 347

Rep: Reputation: 30
I create a directory on the linux box called /Win_remote and I can then mount the windows share:

/bin/mount -t smbfs -o username=<win_user>,password=<win_passwd> //<Win_machine_name>/<sharename> /Win_remote/

Once you've done that you can do anything on any file in the /Win_remote directory. I use it for backing up Windows machines to the server.
 
Old 10-20-2006, 04:13 PM   #5
changlinn
LQ Newbie
 
Registered: Jan 2005
Location: Australia
Distribution: ParrotOS, Kali, Ubunut
Posts: 28

Rep: Reputation: 15
Problem is I think the op and me are actually using Linux workstations.
I have done a lot more research since I posted here, and it is simply not possible to script stuff to work on login that allows for mapping of drives (like windows).
Your best bet, and something I am looking at at the moment, is a multitude of scripts.
My linux pc's that I am testing all this on is a member of the windows domain. So I have a static mount specified to /mnt/linux this is where all my scripts, login, boot, cron-hourly and cron-daily are stored. Various scripts call these. A good one is a method of doing a boot script using a script generator that runs the boot script on the server, script generator here: http://rob.pectol.com/content/view/17/33/ this script is only called once at boot, but you can do things like making sure their /etc/cups/printers.conf is right, this script has full rights.
The next one is the login script, called by ~/.gnomerc which is just simply a file that runs scripts after login, but as the user logging in, so you can't mount drives this way, unless you 755 mount which I guess you could do, but the problem then is mount has no way of grabbing the users current username and password that I am aware of.
The next ones are just hourly and daily scripts to script things like updates, virus scans etc.
The one I am currently looking into, and am hopeful I can get working is pam-mount that can mount shares (can even create the mount points if not available) so eg it takes & as the usersname you can have in your pam-mount.conf hasn't worked so far, but hopefully I can get there.
I'll let you know how I go, I am also writing a guide that I'll put online.
 
Old 10-21-2006, 12:02 PM   #6
achtung_linux
Member
 
Registered: May 2006
Posts: 50

Original Poster
Rep: Reputation: 15
Have anyone had any expirience with Expect? Or maybe tried to solve this kind of problem with Expect and has any expiriences to share?
P.S. Expect is a program that uses Tcl plus its own syntax to script the login and pass commands from a script as if a real user has logged in...
 
Old 10-22-2006, 02:36 AM   #7
changlinn
LQ Newbie
 
Registered: Jan 2005
Location: Australia
Distribution: ParrotOS, Kali, Ubunut
Posts: 28

Rep: Reputation: 15
well got pam-mount working. Very pleased with myself.

Found the below info nowhere else, even on guides to do with pam-mount, found it in some obscure debian guide. This is what made it work.

add this to the end of /etc/pam.d/common-auth
auth optional pam_mount.so use_first_pass

add this to the end of /etc/pam.d/common-session
session optional pam_mount.so

No to figure out if domain logins can be cached so that laptops can be members of the domain but work away from the domain. I don't think they can. The other thing I need to work out is if I can get the Linux workstations to query either Domain controller incase one goes down.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Samba PDC and logon script fdobrovo Linux - Networking 2 12-22-2005 07:10 AM
Samba as PDC: can it just run logon script, not host profiles? hamish Linux - Networking 0 09-09-2005 09:44 AM
samba logon script win xp synfield Linux - Networking 3 08-20-2003 10:24 AM
Samba Logon script not mapping Drives automatically! kofi Linux - Software 0 07-21-2003 03:06 PM
samba logon script question kcourser Linux - Networking 2 04-24-2003 12:45 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 05:24 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration