Sponsored Content
Top Forums Shell Programming and Scripting Statement returning error only launching the sh script via crontab Post 303031663 by bakunin on Monday 4th of March 2019 02:41:57 AM
Old 03-04-2019
Quote:
Originally Posted by mfran2002
Code:
35 10 * * * . $HOME/.bash_profile; /home/myscripts/myscript.sh

the same error
I told you to include the line
Code:
. $HOME/.bash_profile

into your script (myscript.sh) , not call it separately. This way two shells are called: first one shell which executes bash_profile, then this closes, then another shell which executes myscript.sh. The second one is of course not affected by any program that ran before.

And please, when you post code, data or terminal output, use CODE-tags as required by the forum rules.

I hope this helps.

bakunin
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

launching script via REXEC

Hi folks! my client uses an winapplication which is launching shell-scripts remotely on a HP-Unix Machine via Rexec. The application-configuration is launching the script (which is in the home directory of connecting user) like: rexec host user pass shell.sh So far so good, everything... (3 Replies)
Discussion started by: JohnMurdoch
3 Replies

2. Shell Programming and Scripting

Launching a C program that needs input from a shell script

hi there, i need some help, i am trying to run a script to launch a C program and a Java program but before running both I want to get a user input and then invoke both programs with input received. In the programs the inputs are not command line arguments. This is the code, after the java... (4 Replies)
Discussion started by: momal
4 Replies

3. Shell Programming and Scripting

Syntax error in script with if statement

I'm working on a function in a shell script I'm writing that will eventually take in and print out a list of vendor names and aliases (for my work) Here's the function in question: addvendorandalias () { echo echo -n 'Would you like to create a new vendor list (y or n)? ' read answer... (3 Replies)
Discussion started by: Straitsfan
3 Replies

4. AIX

Error launching c++ executable

Hi everybody, I have compiled my code based on the ALPS libraries () and CMake build system with IBM compiler xlC 11.1 on AIX 6.1 at the latest patch level running on an IBM SP Power 6 machine for high-performance computing. When I run the executable I receive this error message: -bash-3.2$... (2 Replies)
Discussion started by: JessicaAlfonsi
2 Replies

5. Shell Programming and Scripting

shell script returning error code 2 from AIX to Mainframe

Hi, I have a shell script which is residing on AIX which is triggered by Mainframe through Connect Direct. The shell script creates several files and sends those files to mainframe using Connect Direct. The shell script is working fine, still it is returning exit code 2 to mainframe. What... (0 Replies)
Discussion started by: Yogesh Aggarwal
0 Replies

6. Shell Programming and Scripting

Script returning an error message on exiting

Hi, I am writing a script in which I am using an IF-Else statement. Code sample: # Check for the product. If (test "$3" = "Pet") Then Product_Code="PI" elif (test "$3" = "Breakdown") Then Product_Code="RI" elif (test "$3" = "Travel") Then Product_Code="TI" ... (2 Replies)
Discussion started by: bghosh
2 Replies

7. Shell Programming and Scripting

error in shell script while returning values-- urgent issue plz help.

Hi, I have initailized a varaible EBID as typeset Long EBID=0 i am calculating value of EBID using certian formula as below: (( CURR_EBID= ($BANDINDEX << 27) | ($CURR_FREQ << 16) | ($CURR_CELLID << 4) | $CURR_SECTOR_VALUE )) return $CURR_EBID The output is as below: + (( CURR_EBID=... (6 Replies)
Discussion started by: kasanur
6 Replies

8. UNIX for Advanced & Expert Users

[Solved] Crontab not launching script

Hi all, i have the following script #!/bin/sh for i in `ps -leaf --cols 1024 | grep LogUser | grep -v grep | awk '{print $4}'`; do echo $i kill -15 $i; done; but it seems that the crontab its sciping this script,i configured corntab as following */30 * * * root... (2 Replies)
Discussion started by: charli1
2 Replies

9. Shell Programming and Scripting

[Solved] FOR loop / IF statement returning error

The code at the bottom is a simplified example of what we have. If I use the following: && echo "echo failed" $? returns 1 When I use if ; then echo "echo failed" ; fi $? returns 0 Does anyone know what's wrong with this? Using AIX 6.1 and KSH for NUM in 1 2 3 do ... (5 Replies)
Discussion started by: jfxdavies
5 Replies

10. Shell Programming and Scripting

Launching mplayer from within Links2 using a shell script

I'm using the Links2 console web browser in graphical mode (the "-g" argument), and launching a shell script that invokes MPlayer from within it. MPlayer works fine. No problem there. The problem, is that I have no control over the MPlayer process. I would like to be able to exit MPlayer whenever... (16 Replies)
Discussion started by: ignatius
16 Replies
keychain(1)						       http://www.funtoo.org						       keychain(1)

NAME
keychain - re-use ssh-agent and/or gpg-agent between logins SYNOPSIS
keychain [ -hkQqV ] [ --clear --help --ignore-missing --noask --nocolor --nogui --nolock --quick --quiet --version ] [ --agents list ] [ --attempts num ] [ --dir dirname ] [ --host name ] [ --lockwait seconds ] [ --stop which ] [ --timeout minutes ] [ keys... ] DESCRIPTION
keychain is a manager for ssh-agent, typically run from ~/.bash_profile. It allows your shells and cron jobs to share a single ssh-agent process. By default, the ssh-agent started by keychain is long-running and will continue to run, even after you have logged out from the system. If you want to change this behavior, take a look at the --clear and --timeout options, described below. When keychain is run, it checks for a running ssh-agent, otherwise it starts one. It saves the ssh-agent environment variables to ~/.keychain/${HOSTNAME}-sh, so that subsequent logins and non-interactive shells such as cron jobs can source the file and make passwordless ssh connections. In addition, when keychain runs, it verifies that the key files specified on the command-line are known to ssh-agent, otherwise it loads them, prompting you for a password if necessary. Keychain also supports gpg-agent in the same ways that ssh-agent is supported. By default keychain attempts to start all available agents but will fall back to only gpg-agent or only ssh-agent if either is unavailable. You can specifically limit keychain using the --agents option. keychain supports most UNIX-like operating systems, including Cygwin. It works with Bourne-compatible, csh-compatible and fish shells. OPTIONS
--agents list Start the agents listed. By default keychain will build the list automatically based on the existence of ssh-agent and/or gpg-agent on the system. The list should be comma-separated, for example "gpg,ssh" --attempts num Try num times to add keys before giving up. The default is 1. --clear Delete all of ssh-agent's keys. Typically this is used in .bash_profile. The theory behind this is that keychain should assume that you are an intruder until proven otherwise. However, while this option increases security, it still allows your cron jobs to use your ssh keys when you're logged out. --confirm Keys are subject to interactive confirmation by the SSH_ASKPASS program before being used for authentication. See the -c option for ssh-add(1). --dir dirname Keychain will use dirname rather than $HOME/.keychain --eval Keychain will print lines to be evaluated in the shell on stdout. It respects the SHELL environment variable to determine if Bourne shell or C shell output is expected. --env filename After parsing options, keychain will load additional environment settings from "filename". By default, if "--env" is not given, then keychain will attempt to load from ~/.keychain/[hostname]-env or alternatively ~/.keychain/env. The purpose of this file is to override settings such as PATH, in case ssh is stored in a non-standard place. -h --help Show help that looks remarkably like this man-page. As of 2.6.10, help is sent to stdout so it can be easily piped to a pager. --host name Set alternate hostname for creation of pidfiles --ignore-missing Don't warn if some keys on the command-line can't be found. This is useful for situations where you have a shared .bash_profile, but your keys might not be available on every machine where keychain is run. --inherit which Attempt to inherit agent variables from the environment. This can be useful in a variety of circumstances, for example when ssh-agent is started by gdm. The following values are valid for "which": local Inherit when a pid (e.g. SSH_AGENT_PID) is set in the environment. This disallows inheriting a forwarded agent. any Inherit when a sock (e.g. SSH_AUTH_SOCK) is set in the environment. This allows inheriting a forwarded agent. local-once Same as "local", but only inherit if keychain isn't already providing an agent. any-once Same as "any", but only inherit if keychain isn't already providing an agent. By default, keychain-2.5.0 and later will behave as if "--inherit local-once" is specified. You should specify "--noinherit" if you want the older behavior. --lockwait seconds How long to wait for the lock to become available. Defaults to 5 seconds. Specify a value of zero or more. If the lock cannot be acquired within the specified number of seconds, then this keychain process will forcefully acquire the lock. --noask This option tells keychain do everything it normally does (ensure ssh-agent is running, set up the ~/.keychain/[hostname]-{c}sh files) except that it will not prompt you to add any of the keys you specified if they haven't yet been added to ssh-agent. --nocolor Disable color hilighting for non ANSI-compatible terms. --nogui Don't honor SSH_ASKPASS, if it is set. This will cause ssh-add to prompt on the terminal instead of using a graphical program. --noinherit Don't inherit any agent processes, overriding the default "--inherit local-once" --nolock Don't attempt to use a lockfile while manipulating files, pids and keys. -k --stop which Kill currently running agent processes. The following values are valid for "which": all Kill all agent processes and quit keychain immediately. Prior to keychain-2.5.0, this was the behavior of the bare "--stop" option. others Kill agent processes other than the one keychain is providing. Prior to keychain-2.5.0, keychain would do this automatically. The new behavior requires that you specify it explicitly if you want it. mine Kill keychain's agent processes, leaving other agents alone. -Q --quick If an ssh-agent process is running then use it. Don't verify the list of keys, other than making sure it's non-empty. This option avoids locking when possible so that multiple terminals can be opened simultaneously without waiting on each other. -q --quiet Only print messages in case of warning, error or required interactivity. As of version 2.6.10, this also suppresses "Identities added" messages for ssh-agent. --timeout minutes Set a timeout in minutes on your keys. This is conveyed to ssh-agent which does the actual timing out of keys since keychain doesn't run continuously. -V --version Show version information. EXAMPLES
This snippet should work in any shell to load two ssh keys and one gpg key: eval `keychain --eval id_rsa id_dsa 0123ABCD` If you have trouble with that in csh: setenv SHELL /bin/csh eval `keychain --eval id_rsa id_dsa 0123ABCD` This is equivalent for Bourne shells (including bash and zsh) but doesn't use keychain's --eval feature: keychain id_rsa id_dsa 0123ABCD [ -z "$HOSTNAME" ] && HOSTNAME=`uname -n` [ -f $HOME/.keychain/$HOSTNAME-sh ] && . $HOME/.keychain/$HOSTNAME-sh [ -f $HOME/.keychain/$HOSTNAME-sh-gpg ] && . $HOME/.keychain/$HOSTNAME-sh-gpg This is equivalent for C shell (including tcsh): keychain id_rsa id_dsa 0123ABCD host=`uname -n` if (-f $HOME/.keychain/$host-csh) then source $HOME/.keychain/$host-csh endif if (-f $HOME/.keychain/$host-csh-gpg) then source $HOME/.keychain/$host-csh-gpg endif To load keychain variables from a script (for example from cron) and abort unless id_dsa is available: # Load keychain variables and check for id_dsa [ -z "$HOSTNAME" ] && HOSTNAME=`uname -n` . $HOME/.keychain/$HOSTNAME-sh 2>/dev/null ssh-add -l 2>/dev/null | grep -q id_dsa || exit 1 SEE ALSO
ssh-agent(1) NOTES
Keychain was created and is currently maintained by Daniel Robbins. If you need to report a bug or request an enhancement, please post to the funtoo-dev mailing list <http://groups.google.com/group/funtoo-dev>. For more information about keychain, please visit <http://www.funtoo.org>. 2.7.1 2010-05-07 keychain(1)
All times are GMT -4. The time now is 01:25 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy