LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Enterprise Linux Forums > Linux - Enterprise
User Name
Password
Linux - Enterprise This forum is for all items relating to using Linux in the Enterprise.

Notices


Reply
  Search this Thread
Old 03-02-2012, 07:34 AM   #1
DrizzyDrake
LQ Newbie
 
Registered: Mar 2012
Posts: 2

Rep: Reputation: Disabled
regex with "if" does not work


Hello All

I'am setting up 2 jumpservers (in a Cluster) at my Company and i'm stuck with a little problem here.

The idea is: If the User is created, /etc/skel will copy a script into the homedir of every user.
This script should be executable only by regular users, which names are like "tkfoo". tk or tx at the beginning, followed by three letters and/or numbers.

If i execute this script with root, it will not allow to sync the homedir. When i execute this with a tk... or tx... user it should run and sync the homedirs, but it doesn't.
I get the Error message: "You are not permitted to rsync your homedir as user $USER, you have to be tk*** or tx***"
I thought that =~ should work, but it doesnt. I don't know how i should get it to work, any help is appreciated.

Anyways, here is the tiny script:
Code:
#!/bin/bash
DEST="server02"
BACKDIR="/home/$USER"
DESTDIR="/home/$USER"
OPTS="-avvz --delete --exclude="^.*" --log-file=/var/log/rsync.log"

if [[ "$USER" =~ "t[k|x]..." ]]; then
    rsync $OPTS $BACKDIR $USER@$DEST:$DESTDIR
else
    echo "You are not permitted to rsync your homedir as user $USER, you have to be tk*** or tx***"
fi
I apologize for any english mistakes, I hope you can imagine what I'm trying to do.

Last edited by DrizzyDrake; 03-02-2012 at 07:49 AM.
 
Old 03-02-2012, 07:50 AM   #2
whizje
Member
 
Registered: Sep 2008
Location: The Netherlands
Distribution: Slackware64 current
Posts: 594

Rep: Reputation: 141Reputation: 141
try this
Code:
if [[ $USER = t[kx]* ]]; then
 
Old 03-02-2012, 07:52 AM   #3
DrizzyDrake
LQ Newbie
 
Registered: Mar 2012
Posts: 2

Original Poster
Rep: Reputation: Disabled
Thanks!

Well that did it.
It works!
I tried like 10 different things and nothing worked.

Many thanks to you!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
evdev/xorg help? USB mouse/kbd: 2.6.24="just works">2.6.25="unplug/replug to work". GrapefruiTgirl Linux - Hardware 4 12-13-2012 02:23 PM
Using " find " with " -regex " Some help needed..!! WhisperiN Linux - Newbie 6 10-11-2010 03:30 PM
A single regex to match anything with ".aac" or ".mp3" at the end ? lumix Linux - General 9 05-09-2008 01:11 AM
Any way to get "Alice"; "Call of Duty" series and "Descent 3" to work? JBailey742 Linux - Games 13 06-23-2006 01:34 PM
"<" ">" Keyboard keys on Toshiba Satellite 1005-s157 dont work RodCas Linux - Laptop and Netbook 1 05-08-2004 04:22 PM

LinuxQuestions.org > Forums > Enterprise Linux Forums > Linux - Enterprise

All times are GMT -5. The time now is 08:40 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