PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Serveur - Sécurité et techniques > comp.unix.shell > Inheriting proper env for crontab
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
comp.unix.shell Using and programming the Unix shell.

Inheriting proper env for crontab

Réponse
 
LinkBack Outils de la discussion
Vieux 17/07/2007, 22h46   #1
dn.perl@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Inheriting proper env for crontab

When I login as 'scott' , I can successfully execute a shell-script
which calls 'sqlplus' command from it. But I am unable to execute it
as cron job because sqlplus does not execute properly.

I logged in as 'scott', and added the following line to crontab :
5 * * * * full_path/my_cmd param1 param2
But it does not work.
I get the error : ORA-07217 : sltln: environemnt variable cannot be
evaluated.

So I modified crontab entry to :
5 * * * * /usr/bin/su scott -c full_path/my_cmd param1 param2
This generates the error : su : Sorry.
Presumably it expects the user's (scott's) password to be supplied.

So I logged in as root and added an entry to crontab :
5 * * * * /usr/bin/su scott -c full_path/my_cmd param1 param2
This has better success but when I executes my_cmd, it does not find
the command sqlplus because sqlplus is not in its PATH .

So I logged in as root and added an entry to crontab :
5 * * * * /usr/bin/su scott -c full_path/interm_script

Then in this intermediate_script, I exported PATH=$PATH:/apps/oracle/
bin
This has better success because sqlplus is now in its PATH . But I
still get the error :
Message file sp1<lang>.msb not found.
Error 6 initializing SQL*Plus.

Ideally I would like to manipulate just my own crontab, instead of the
root's crontab. Ability to somehow pass password to 'su' command
in a crontab line might be crucial to achieving this. I do not know
how to manage it.

But even if the root can set up a proper cronjob, I will be happy.

Please advise. Thanks in advance.

  Réponse avec citation
Vieux 18/07/2007, 09h21   #2
Michael Tosch
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Inheriting proper env for crontab

dn.perl@gmail.com wrote:
> When I login as 'scott' , I can successfully execute a shell-script
> which calls 'sqlplus' command from it. But I am unable to execute it
> as cron job because sqlplus does not execute properly.
>
> I logged in as 'scott', and added the following line to crontab :
> 5 * * * * full_path/my_cmd param1 param2
> But it does not work.
> I get the error : ORA-07217 : sltln: environemnt variable cannot be
> evaluated.
>
> So I modified crontab entry to :
> 5 * * * * /usr/bin/su scott -c full_path/my_cmd param1 param2
> This generates the error : su : Sorry.
> Presumably it expects the user's (scott's) password to be supplied.
>
> So I logged in as root and added an entry to crontab :
> 5 * * * * /usr/bin/su scott -c full_path/my_cmd param1 param2
> This has better success but when I executes my_cmd, it does not find
> the command sqlplus because sqlplus is not in its PATH .
>
> So I logged in as root and added an entry to crontab :
> 5 * * * * /usr/bin/su scott -c full_path/interm_script
>
> Then in this intermediate_script, I exported PATH=$PATH:/apps/oracle/
> bin
> This has better success because sqlplus is now in its PATH . But I
> still get the error :
> Message file sp1<lang>.msb not found.
> Error 6 initializing SQL*Plus.
>
> Ideally I would like to manipulate just my own crontab, instead of the
> root's crontab. Ability to somehow pass password to 'su' command
> in a crontab line might be crucial to achieving this. I do not know
> how to manage it.
>
> But even if the root can set up a proper cronjob, I will be happy.
>
> Please advise. Thanks in advance.
>


Because su -c starts a sub shell, you must quote the words,
so the current shell sees one string (argument),
while the sub shell sees the words (arguments):

su scott -c "full_path/my_cmd param1 param2"


--
Michael Tosch @ hp : com
  Réponse avec citation
Vieux 18/07/2007, 14h04   #3
Bill Marcum
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Inheriting proper env for crontab

On Tue, 17 Jul 2007 21:46:18 -0000, dn.perl@gmail.com
<dn.perl@gmail.com> wrote:
>
> Then in this intermediate_script, I exported PATH=$PATH:/apps/oracle/
> bin
> This has better success because sqlplus is now in its PATH . But I
> still get the error :
> Message file sp1<lang>.msb not found.
> Error 6 initializing SQL*Plus.
>

You may need to set LANG as it is set when you log in.

> Ideally I would like to manipulate just my own crontab, instead of the
> root's crontab. Ability to somehow pass password to 'su' command
> in a crontab line might be crucial to achieving this. I do not know
> how to manage it.
>

You shouldn't need su to execute a script as yourself. You just need
to set the proper environment variables.


--
Education is learning what you didn't even know you didn't know.
-- Daniel J. Boorstin
  Réponse avec citation
Vieux 20/07/2007, 19h06   #4
Miles
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Inheriting proper env for crontab

On Jul 17, 4:46 pm, "dn.p...@gmail.com" <dn.p...@gmail.com> wrote:
> When I login as 'scott' , I can successfully execute a shell-script
> which calls 'sqlplus' command from it. But I am unable to execute it
> as cron job because sqlplus does not execute properly.
>
> I logged in as 'scott', and added the following line to crontab :
> 5 * * * * full_path/my_cmd param1 param2
> But it does not work.
> I get the error : ORA-07217 : sltln: environemnt variable cannot be
> evaluated.
>
> So I modified crontab entry to :
> 5 * * * * /usr/bin/su scott -c full_path/my_cmd param1 param2
> This generates the error : su : Sorry.
> Presumably it expects the user's (scott's) password to be supplied.
>
> So I logged in as root and added an entry to crontab :
> 5 * * * * /usr/bin/su scott -c full_path/my_cmd param1 param2
> This has better success but when I executes my_cmd, it does not find
> the command sqlplus because sqlplus is not in its PATH .
>
> So I logged in as root and added an entry to crontab :
> 5 * * * * /usr/bin/su scott -c full_path/interm_script
>
> Then in this intermediate_script, I exported PATH=$PATH:/apps/oracle/
> bin
> This has better success because sqlplus is now in its PATH . But I
> still get the error :
> Message file sp1<lang>.msb not found.
> Error 6 initializing SQL*Plus.
>
> Ideally I would like to manipulate just my own crontab, instead of the
> root's crontab. Ability to somehow pass password to 'su' command
> in a crontab line might be crucial to achieving this. I do not know
> how to manage it.
>
> But even if the root can set up a proper cronjob, I will be happy.
>
> Please advise. Thanks in advance.


I'm pretty sure you want su - scott -c. You need the " - " get the the
users env.
Miles

  Réponse avec citation
Vieux 29/07/2007, 21h58   #5
Jim Jackson
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Inheriting proper env for crontab

dn.perl@gmail.com <dn.perl@gmail.com> wrote:
> When I login as 'scott' , I can successfully execute a shell-script
> which calls 'sqlplus' command from it. But I am unable to execute it
> as cron job because sqlplus does not execute properly.


On some cron implementations, you can specify environment variables
in the head of the crontab entry. Check man page "man 5 crontab"

> I logged in as 'scott', and added the following line to crontab :
> 5 * * * * full_path/my_cmd param1 param2
> But it does not work.
> I get the error : ORA-07217 : sltln: environemnt variable cannot be
> evaluated.


> So I modified crontab entry to :
> 5 * * * * /usr/bin/su scott -c full_path/my_cmd param1 param2
> This generates the error : su : Sorry.
> Presumably it expects the user's (scott's) password to be supplied.


> So I logged in as root and added an entry to crontab :
> 5 * * * * /usr/bin/su scott -c full_path/my_cmd param1 param2
> This has better success but when I executes my_cmd, it does not find
> the command sqlplus because sqlplus is not in its PATH .


> So I logged in as root and added an entry to crontab :
> 5 * * * * /usr/bin/su scott -c full_path/interm_script


> Then in this intermediate_script, I exported PATH=$PATH:/apps/oracle/
> bin
> This has better success because sqlplus is now in its PATH . But I
> still get the error :
> Message file sp1<lang>.msb not found.
> Error 6 initializing SQL*Plus.


> Ideally I would like to manipulate just my own crontab, instead of the
> root's crontab. Ability to somehow pass password to 'su' command
> in a crontab line might be crucial to achieving this. I do not know
> how to manage it.


> But even if the root can set up a proper cronjob, I will be happy.


> Please advise. Thanks in advance.


  Réponse avec citation
Vieux 29/07/2007, 23h04   #6
Joe
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Inheriting proper env for crontab

"dn.perl@gmail.com" <dn.perl@gmail.com> writes:

> When I login as 'scott' , I can successfully execute a shell-script
> which calls 'sqlplus' command from it. But I am unable to execute it
> as cron job because sqlplus does not execute properly.
>
> I logged in as 'scott', and added the following line to crontab :
> 5 * * * * full_path/my_cmd param1 param2
> But it does not work.
> I get the error : ORA-07217 : sltln: environemnt variable cannot be
> evaluated.


If my_cmd is a script, source the startup files for scott. If it's a
binary, wrap it in a script which does that, then calls my_cmd.

You can't depend on any particular environment being active in a cron
job, if you need one you just have to arrange for it to get setup.

Joe
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 12h31.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,17550 seconds with 14 queries