Results 1 to 3 of 3

Thread: Running at as a one-liner

  1. #1
    Junior Member
    Join Date
    Apr 2012
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Post Running at as a one-liner

    Hey nixcraft and welcome to my first post,
    I think it's easy for you to solve and no big deal, but for me this is rather hard to accomplish as I'm pretty new to the wonderful world of linux.
    The environment is a Debian 6 VM without KDE / GNOME / X11 or sth.
    I'm trying to get the ability to create accounts which expire (disallow login)..let's say 3 hours after creation. The first things are no problem for me:
    Code:
    useradd username --no-create-home --shell /bin/false
    echo username:password | chpasswd
    But the expiry date really sucks for me. The options I had were:
    chage
    Chage was knocked out very fast, as it only accepts dates, no hours or minutes.
    cron
    I think it's better to use cron for recurring activities, but not for '1-time' use.
    at
    At seems to work like a charm, but as I want to include everything in a PHP script (don't worry, I've made my homework consulting the security. The script is limited to my and only my IP adress, also the 'server' this runs on is only a virtual machine on my PC, so security is not a big deal yet) I'd prefer to have everything wrapped in one line, not the standard procedure, which is like at now + 3 hours, > command here, STRG+D.
    At seems to accept input from a file with the -f flag. But I don't want to create a file for every user, delete it and so on.
    I thought about something like:
    Code:
    at now + 3 hours | echo 'run this command'

    (Pipelined input or something, not sure about it
    )
    But that won't work, and it was the only solution I could imagine.
    Please help me to get this running ASAP, help is highly appreciated.
    Breaking Point

  2. #2
    Never say die nixcraft's Avatar
    Join Date
    Jan 2005
    Location
    BIOS
    Posts
    4,513
    Thanks
    17
    Thanked 807 Times in 511 Posts
    Rep Power
    10

    Default

    How about?

    Code:
    at now + 3 hours <<EOF
    command1
    command2
    EOF
    All [Solved] threads are closed by mods / admin to avoid spam issues. See Howto mark a thread as [Solved]


  3. The Following User Says Thank You to nixcraft For This Useful Post:

    breakingpoint (4th April 2012)

  4. #3
    Junior Member
    Join Date
    Apr 2012
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Default

    Hello nixcraft,
    thanks for your answer, but I'm not getting it so far.
    I believe the use of EOF refers to some sort of Linux-Style Syntax here, if so, there's a little problem.
    PHP uses a syntax that pretty much matches this eof-syntax called Heredoc or its successor Nowdoc, which look like this when used
    Code:
    echo <<< HTML
    <span>$hello</span>
    HTML;
    So is there any alternative or do I have to find a way of escaping the characters to get PHP to print me this <<eof?
    Thanks in advance,
    Breaking Point

    Aaaah, possible solution
    You need to wrap everything in a variable in order for it to work correctly, then concatenate a string out of it...looks pretty shitty.
    Code:
    $v1 = '<';
    $v2 = '<';
    $eof = ' EOF';
    [...]
    $buildcmd = $v1.$v2.$eof.$atc;
    Update! What's written above won't work. I misstyped 'EOF' and it became ' EOF '. with the 2 whitespaces there's no problem with concatenating it, but once you write 'EOF ' it is going to fail.
    Further help is still appeciated.
    Last edited by breakingpoint; 5th April 2012 at 12:12 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Running yum problem
    By t0kneneng in forum CentOS / RHEL / Fedora
    Replies: 5
    Last Post: 3rd March 2010, 04:57 PM
  2. [Solved] web application not running
    By amarishvenugopal in forum Web servers
    Replies: 5
    Last Post: 31st December 2009, 08:39 AM
  3. Running php as root
    By Leszek.T in forum Ubuntu / Debian
    Replies: 9
    Last Post: 1st October 2009, 05:53 PM
  4. Getting Squid 3.0 up and running
    By Mic in forum Linux software
    Replies: 4
    Last Post: 18th May 2008, 03:56 PM
  5. How long the sys was running?
    By jithendra in forum Linux software
    Replies: 2
    Last Post: 16th October 2006, 05:31 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •