running shelly script from root's crontab

Hi I have a shelly script that runs fine from my user account which I would to run every night. It needs to sudo to call some other processes so I need to add it to the root's crontab (sudo crontab -e). Unfortunately the script will fail to run because it can't find several modules, since it's running from the root account. Is there a way to make this work without having to install the packages globally (sudo cabal install --globally) ? I just tried that and manage to completely ruin my haskell installation, so I had to revert to previous backup. thanks, -- Miguel Negrão http://www.friendlyvirus.org/miguelnegrao

Hi, Dnia 2013-07-12, pią o godzinie 14:39 +0100, Miguel Negrão pisze:
Hi
I have a shelly script that runs fine from my user account which I would to run every night. It needs to sudo to call some other processes so I need to add it to the root's crontab (sudo crontab -e). Unfortunately the script will fail to run because it can't find several modules, since it's running from the root account. Is there a way to make this work without having to install the packages globally (sudo cabal install --globally) ? I just tried that and manage to completely ruin my haskell installation, so I had to revert to previous backup.
Try: 'su - user_name' Best regards, Emanuel

Miguel Negrão
I have a shelly script that runs fine from my user account which I would to run every night. It needs to sudo to call some other processes so I need to add it to the root's crontab (sudo crontab -e). Unfortunately the script will fail to run because it can't find several modules, since it's running from the root account. Is there a way to make this work without having to install the packages globally (sudo cabal install --globally) ? I just tried that and manage to completely ruin my haskell installation, so I had to revert to previous backup.
Miguel, it sounds like you're using `runhaskell' to execute your code. Is there any reason you can't compile the code using GHC? With an executable binary you wouldn't need anything from Haskell available to the root user. -- Peter Jones, Founder, Devalot.com Defending the honor of good code

Hi Peter, Em 12-07-2013 15:02, Peter Jones escreveu:
Miguel Negrão
writes: I have a shelly script that runs fine from my user account which I would to run every night. It needs to sudo to call some other processes so I need to add it to the root's crontab (sudo crontab -e). Unfortunately the script will fail to run because it can't find several modules, since it's running from the root account. Is there a way to make this work without having to install the packages globally (sudo cabal install --globally) ? I just tried that and manage to completely ruin my haskell installation, so I had to revert to previous backup.
Miguel, it sounds like you're using `runhaskell' to execute your code. Is there any reason you can't compile the code using GHC? With an executable binary you wouldn't need anything from Haskell available to the root user.
Indeed, I was using runhaskell to avoid the compile step, but off course, the obvious solution is to compile to a binary, that works perfectly ! thanks, -- Miguel Negrão http://www.friendlyvirus.org/miguelnegrao
participants (3)
-
Emanuel Koczwara
-
Miguel Negrão
-
Peter Jones