Sponsored Content
Top Forums Shell Programming and Scripting When i am trying to execute export command within a shell script it is saying command not found. Post 302657239 by methyl on Saturday 16th of June 2012 09:05:03 PM
Old 06-16-2012
Let's lose all the surplus Shell syntax, remove, move, or correct many quote characaters, and just execute the command.
There is an issue with $TMPDIR because the value can only come from the login script. Let's assume that it has a value, otherwise every line mentioning $TMPDIR will fail.
I have no idea what is in /usr/atria/bin/cleartool but there is no possible way that a called process executed in this manner can change the environment of the calling process.

Code:
#!/bin/sh
user="test"
DIR="/bldtmp/$user"
VIEW="test.view1"
echo "TMPDIR before export : $TMPDIR"
/usr/atria/bin/cleartool setview -exec "export TMPDIR=$DIR/tmp"
export UNPACKDIR="$TMPDIR/unpackdir"
echo "After Export: $TMPDIR  $VIEW"

Assuming that /usr/atria/bin/cleartool is a Shell Script, it would need to execute in the current Shell environment if it was to change the current Shell environment.

Perhaps:
Code:
. ./usr/atria/bin/cleartool

i.e dot-space-dot-slash-scriptname

Last edited by methyl; 06-16-2012 at 10:14 PM.. Reason: typos and addenda
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

shell script to execute user command

I don't know why the following shell script doesn't work. Could you please help me out? #!/usr/bin/ksh test="cal > /tmp/tmp.txt 2>&1" $test I know it will work for the following format: #!/usr/bin/ksh cal > /tmp/tmp.txt 2>&1 However, I need to get the command from the user in... (1 Reply)
Discussion started by: redtiger
1 Replies

2. UNIX for Dummies Questions & Answers

ExporT Command Not found

Hi All I am getting and error export command not found What can be the possible reasons for this and how do we verify those Please help me Thanks (1 Reply)
Discussion started by: networking
1 Replies

3. Shell Programming and Scripting

write a shell script to execute a command

Hello all, I have just started doing shell scripting. I want to read a file which stores the status of my job I have submitted on a cluster. The file looks something like this : ========================FILE============================= crab: Checking the status of all jobs: please wait... (4 Replies)
Discussion started by: learn_linux
4 Replies

4. Shell Programming and Scripting

Execute a shell script after a particular command is run

Hi, I need to run a script whenever the Cron file is modified. The requirement is whenever a user modifies the cron file, the script should run automatically. Can you please provide your inputs ? (5 Replies)
Discussion started by: harneet2004us
5 Replies

5. Shell Programming and Scripting

rm:command not found in linux Bash shell script

Hi All, Linux lxs3er06 2.6.9-67.ELsmp #1 SMP Wed Nov 7 13:58:04 EST 2007 i686 i686 i386 GNU/Linux Issue: While executing shell scripts in bash shell, following error messages are thrown: rm:command not found On doing little investigation, I added '/bin' to $PATH and on doing echo... (9 Replies)
Discussion started by: a1_win
9 Replies

6. Shell Programming and Scripting

Command not found in shell script - stumped for 4 days

Hello, I like to begin with :wall:.. literally... It has been 4 days and I have no idea how to fix it. Environment - AIX 5.3 I wrote a script to call on ssh to log into another box via PKA to do something else. If I run the script on the terminal, it works 100%. If the SAP customised... (11 Replies)
Discussion started by: plonkagain
11 Replies

7. UNIX for Dummies Questions & Answers

ssh command to execute shell script in another server

ssh -q <hostname> /opt/tcs/satish/tst.ksh ssh -q <anotherserver> /opt/tcs/satish/tst.ksh tst.ksh has "nohup <command> & " when i execute below script , its throwing error as nohup can not be found ssh -q <anotherserver> /opt/tcs/satish/tst.ksh > log & can someone let me... (5 Replies)
Discussion started by: only4satish
5 Replies

8. UNIX for Dummies Questions & Answers

How to execute command after telneting in shell script?

Hi , I have to write a shell script to telnet to specific host and execute the admin command there. Please help me to do that. Eg : telnet hostname portno admin command exit (3 Replies)
Discussion started by: arukuku
3 Replies

9. Shell Programming and Scripting

Need to execute Oracle relocation command in shell script

Hello, I need to execute below command in shell script srvctl relocate service -d $database -s $service -i $avail -t $pref -f and also need to get the errors ,if any,in another file. What's the right way to execute such commands in shell script? Best regards, Vishal (1 Reply)
Discussion started by: Vishal_dba
1 Replies

10. Shell Programming and Scripting

How to execute application command in shell script?

friends, i have application commands to execute in shell script it is something like this. i will login with user data it takes me to $ prompt. Example given below login: data ps : xxxx $ MNSinput --this takes me to greater than prompt > > ops --this is command i enter this output... (7 Replies)
Discussion started by: udaykrishna
7 Replies
mktemp(1)							   User Commands							 mktemp(1)

NAME
mktemp - make temporary filename SYNOPSIS
mktemp [-dtqu] [-p directory] [template] DESCRIPTION
The mktemp utility makes a temporay filename. To do this, mktemp takes the specified filename template and overwrites a portion of it to create a unique filename. See OPERANDS. The template is passed to mktemp(3C) for directories or mkstemp(3C) for ordinary files. If mktemp can successfully generate a unique filename, the file (or directory) is created with file permissions such that it is only read- able and writable by its owner (unless the -u flag is given) and the filename is printed to standard output. mktemp allows shell scripts to safely use temporary files. Traditionally, many shell scripts take the name of the program with the PID as a suffix and used that as a temporary filename. This kind of naming scheme is predictable and the race condition it creates is easy for an attacker to win. A safer, though still inferior approach is to make a temporary directory using the same naming scheme. While this guaran- tees that a temporary file is not subverted, it still allows a simple denial of service attack. Use mktemp instead. OPTIONS
The following options are supported: -d Make a directory instead of a file. -p directory Use the specified directory as a prefix when generating the temporary filename. The directory is overridden by the user's TMPDIR environment variable if it is set.This option implies the -t flag. -q Fail silently if an error occurs.This is useful if a script does not want error output to go to standard error. -t Generate a path rooted in a temporary directory. This directory is chosen as follows: If the user's TMPDIR environ- ment variable is set, the directory contained therein is used. Otherwise, if the -p flag was given the specified directory is used. If none of the above apply, /tmp is used. In this mode, the template (if specified) should be a directory component (as opposed to a full path) and thus should not contain any forward slashes. -u Operate in unsafe mode. The temp file is unlinked before mktemp exits. This is slightly better than mktemp(3C), but still introduces a race condition. Use of this option is discouraged. OPERANDS
The following operands are supported: template template can be any filename with one or more Xs appended to it, for example /tmp/tfile.XXXXXX. If template is not specified, a default of tmp.XXXXXX is used and the -t flag is implied. EXAMPLES
Example 1: Using mktemp The following example illustrates a simple use of mktemp in a sh(1) script. In this example, the script quits if it cannot get a safe tem- porary file. TMPFILE=`mktemp /tmp/example.XXXXXX` if [ -z "$TMPFILE" ]; then exit 1; fi echo "program output" >> $TMPFILE Example 2: Using mktemp to Support TMPDIR The following example uses mktemp to support for a user's TMPDIR environment variable: TMPFILE=`mktemp -t example.XXXXXX` if [ -z "$TMPFILE" ]; then exit 1; fi echo "program output" >> $TMPFILE Example 3: Using mktemp Without Specifying the Name of the Temporary File The following example uses mktemp without specifying the name of the temporary file. In this case the -t flag is implied. TMPFILE=`mktemp` if [ -z "$TMPFILE" ]; then exit 1; fi echo "program output" >> $TMPFILE Example 4: Using mktemp with a Default Temporary Directory Other than /tmp The following example creates the temporary file in /extra/tmp unless the user's TMPDIR environment variable specifies otherwise: TMPFILE=`mktemp -p /extra/tmp example.XXXXX` if [ -z "$TMPFILE" ]; then exit 1; fi echo "program output" >> $TMPFILE Example 5: Using mktemp to Remove a File The following example attempts to create two temporary files. If creation of the second temporary file fails, mktemp removes the first file before exiting: TMP1=`mktemp -t example.1.XXXXXX` if [ -z "$TMP1" ]; then exit 1; fi TMP2=`mktemp -t example.2.XXXXXX` if [ -z "$TMP2" ]; then rm -f $TMP1 exit 1 fi Example 6: Using mktemp The following example does not exit if mktemp is unable to create the file. That part of the script has been protected. TMPFILE=`mktemp -q -t example.XXXXXX` if [ ! -z "$TMPFILE" ] then # Safe to use $TMPFILE in this block echo data > $TMPFILE ... rm -f $TMPFILE fi ENVIRONMENT VARIABLES
See environ(5) for descriptions of the following environment variables that affect the execution of mktemp with the -t option: TMPDIR. EXIT STATUS
The following exit values are returned: 0 Successful completion. 1 An error occurred. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ |Interface Stability |Evolving | +-----------------------------+-----------------------------+ SEE ALSO
sh(1), mkstemp(3C), mktemp(3C), attributes(5), environ(5) NOTES
The mktemp utility appeared in OpenBSD 2.1. The Solaris implementation uses only as many `Xs' as are significant for mktemp(3C) and mkstemp(3C). SunOS 5.10 4 Jun 2004 mktemp(1)
All times are GMT -4. The time now is 02:21 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy