not able to execute script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting not able to execute script
# 1  
Old 09-29-2008
not able to execute script

hi,
I have 2 questions

Ques1.) I have one script(profile.ksh) and I execting it by
# ./profile.ksh
./profile.ksh: bad substitution

and when I am using
ksh profile.ksh ----it is running.
but other scripts are running fine.

So can any1 tell me what is wrong with it Smilie

Ques2.) in profile.ksh I want to set some envirnment variable but I am not able to set it

I am writing some variables which I have to set

COMMON_USER_HOME=${HOME}
export COMMON_USER_HOME
echo COMMON_USER_HOME=$COMMON_USER_HOME

export P4USER="AbcdeF"
echo P4USER=$P4USER

but when I am running my file profile.ksh and echoing the variable then I am able to see the output of the variables:

# echo $SHELL
/bin/sh

COMMOM_USER_HOME=/home/User1
P4USER=AbcdeF

but not able to see it as exported when using set commond Smilie
# 2  
Old 09-29-2008
For 1) try having the first line in the script like:
Code:
#!/usr/bin/ksh

or whatever your path to your Korn Shell is.

For 2)
To see which variables are exportet, use something like
Code:
env| grep <nameofyourvariable>

That you can see the value with echo is a good sign.
Afaik, with set, you only see what is in your current shell, not which has necessarily been exported.
You can test it by just using set A=1 and then use set. You will see it, but not when you use env.

Example:
Code:
root@isau02:/tmp> A=1
root@isau02:/tmp> set| grep ^A
A=1
root@isau02:/tmp> env| grep ^A
root@isau02:/tmp> export A=1
root@isau02:/tmp> set| grep ^A
A=1
root@isau02:/tmp> env| grep ^A
A=1

After exporting you can start another shell from your current session and do "env| grep <yourvariablesname>" and will see that it has been definetly exported.
# 3  
Old 09-29-2008
thanks a lot,My 1st problem is solved :-)

but for 2nd,when I am using
# env | grep P4USER
# env | grep COMMON_USER_HOME

it is executing but not able to see the anything and when I am trying it by using

# echo $P4User

# echo $COMMON_USER_HOME

#

it means,it is not been set..
# 4  
Old 09-29-2008
It would help if you could post the file profile.ksh here so we don't have to speculate about what could be wrong.
# 5  
Old 09-29-2008
In addition: If you are just having variables in this script, it might be a way to just source this enviornment file, which would export all variables automatically. Sourcing means that you have a single dot in front of the script, when calling it. This could be done one the promt and also in some other script like .profile, which would be called at login automatically.

Example:
Code:
cat env_one
A=1
B=2

#then
. ./env_one

#start another shell to see if it's exported
ksh
env| grep -E "^A|^B"

# 6  
Old 09-29-2008
No,I don't have variables in my script.I have more other operations in that.for my application I have to set the variable and after using that I am unsetting those variables.

I want it from my script,I am not able to understand why they are not being set by the script ??
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Execute a script based on status of embedded script

Hi, I have 2 scripts, first.ksh and second.ksh and would like first.ksh to run based on response of 'Y/y' received for second.ksh but in my case it continues to execute 'rm /tmp/list' irrespective of response received, below are my scripts with further info, Hope I'm making sense :) Thanks! ... (1 Reply)
Discussion started by: mbak
1 Replies

2. Shell Programming and Scripting

Batch script to execute shell script in UNIX server

Hi team, My requirement is to transfer pdf files from windows machine to unix server and then from that unix server we should sftp to another server. I have completed the first part i.e From windows to using to unix server with the help of psftp.exe code: psftp user@host -pw password <... (1 Reply)
Discussion started by: bhupeshchavan
1 Replies

3. Linux

How to execute a simple select script using a shell script?

Hi team, I have two select statements and need to run them using SYSDBA user select * from temp_temp_seg_usage; select segment_name, tablespace_name, bytes/ (1024*1024) UsedMb from dba_segments where segment_name='TEMP_TEMP_SEG_USAGE'; Need to run this using a shell script say named... (1 Reply)
Discussion started by: pamsy78
1 Replies

4. Solaris

Need to execute the script with script name wihtout using ./scriptname in Solaris 10

Hi, I am using solaris 10.Is there any way to execute the script with the scriptname wihtoug using ./scriptname?Also does it varies from shell to shell.I have scripts in bash,ksh,sh shells. Example:script.sh is the script name.I need to execute the script like this script.sh instead... (4 Replies)
Discussion started by: muraliinfy04
4 Replies

5. Programming

CGI Perl script to execute bash script- unable to create folder

Hi I have a bash script which takes parameters sh /tmp/gdg.sh -b BASE-NAME -n 1 -s /source/data -p /dest/data/archive -m ARC gdg.sh will scan the /source/data and will move the contents to /dest/data/archive after passing through some filters. Its working superb from bash I have... (0 Replies)
Discussion started by: rakeshkumar
0 Replies

6. Shell Programming and Scripting

Expect script to execute a script on a remote host

Hi, I am new to the expect scripting. I have this expect script as below : spawn ssh remote_server -l id set pass "12345" set opt "s" expect "Password:" {send "$pass\r" ; } expect "*ENTER*" {send "Enter\r"; exp_continue } expect "Please select option :" {send... (2 Replies)
Discussion started by: curt137
2 Replies

7. Shell Programming and Scripting

Dos batch script to execute unix shell script

Can anyone help me with a dos batch script to execute a shell script residing in an unix server. I am not able to use ssh. Thanks in advance (2 Replies)
Discussion started by: Shri123
2 Replies

8. Shell Programming and Scripting

execute script without displaying child script messages

Hi i have a script which is calling another script. But my child script is displaying some values. sample script. export LOG_File=/log $/Project/Scripts/emit.ksh mv inner_test.ksh /log/test.ksh echo 'Success' here emit.ksh is doing some processing .and echoing some values. what i... (2 Replies)
Discussion started by: kam786sim
2 Replies

9. Shell Programming and Scripting

Execute unix shell script to text file using the script

Hi all, I am beginner in UNIX...I want to use unix shell script to create text.file...I know how to use using by command...can anybody tell me for the script? Thanks i changed the threads title from "tex file" to "text file", because "tex" would probably be misunderstood as reference to... (4 Replies)
Discussion started by: mastercar
4 Replies

10. Shell Programming and Scripting

script execute or no execute

o hola.. Tengo un script que se ejecuta bajo una tarea del CronJOb del unix, tengo la version 11 de unix, mi script tiene un ciclo que lee unos archivos .txt luego cada uno de esos archivos debe pasar por un procedimiento almacenado el cual lo tengo almacenado en mi base de datos oracle 10g,... (4 Replies)
Discussion started by: Kespinoza97
4 Replies
Login or Register to Ask a Question