Bash script variables question[Scanned]

Chris Bradford chrisbradford at cambridge-news.co.uk
Sun Aug 6 11:44:57 UTC 2006


Chris Bradford wrote:
> Hi guys,
>
> I'm putting together a simple login script for bash where I call a 
> zenity box that has an IT Policy for our company.
>
> If the user accepts the policy I want this acceptance to be echoed, 
> along with the host name of the machine they are on and the time, into 
> a text file on a mounted network share. The script I have so far is:
>
> #!/bin/sh
>
> ctime=/bin/date
> compname=hostname
>
> if zenity --question --title "Cambridge Newspapers IT Policy" --text 
> "By logging intothis workstation you accept that you are bound to the 
> IT Policy. \n\nIf you do not accept this policy please selcet Cancel 
> to logoff, otherwise press OK to continue."
>
> then
>     echo $USER "accepted User IT Policy @" $ctime "from" $compname
> else
>     echo "Logoff"
>     # remove the echo and speach marks
>     echo 'killall gnome-session'
> fi
>
> But the date is not echoed, only the string 'date' and 'hostname' does 
> the same. Can anyone tell me where I am going wrong?
>
> Thanks in advance,
>
> -Chris
>
>
> This message has been scanned for viruses by BlackSpider MailControl - 
> www.blackspider.com
>
Nevermind!

I changed

ctime=/bin/date
compname=hostname

to:

ctime="$(date)"
compname="$(hostname)"

And it works now,

Cheers,

-Chris




More information about the fedora-list mailing list