Query regarding ksh


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Query regarding ksh
# 1  
Old 04-05-2007
Error Query regarding ksh

I wrote a script in ksh as follow:

echo "Hello"

if [ $# -eq 0 ]; then
echo "bye"
else
echo "Welcome"
fi

i ran this script two time with different syntax like this:

~/my_temp [151]> ./test.ksh
Hello
bye

~/my_temp [152]> test.ksh
WIDTH: 12
WIDTH: 17
RELEASE [06.12.00.00]


Any idea why i am getting two different outputs and whats then meaning of second output.
# 2  
Old 04-05-2007
Quote:
Originally Posted by vaibhav
I wrote a script in ksh as follow:

echo "Hello"

if [ $# -eq 0 ]; then
echo "bye"
else
echo "Welcome"
fi

i ran this script two time with different syntax like this:

~/my_temp [151]> ./test.ksh
Hello
bye

~/my_temp [152]> test.ksh
WIDTH: 12
WIDTH: 17
RELEASE [06.12.00.00]


Any idea why i am getting two different outputs and whats then meaning of second output.
You are inovking your script from the current working directory using ./
The other command could be picking up something from the path

I have run your script under bash and ksh and not got this unusual output.
# 3  
Old 04-05-2007
Quote:
Originally Posted by vaibhav
I wrote a script in ksh as follow:

echo "Hello"

if [ $# -eq 0 ]; then
echo "bye"
else
echo "Welcome"
fi

i ran this script two time with different syntax like this:

~/my_temp [151]> ./test.ksh
Hello
bye

~/my_temp [152]> test.ksh
WIDTH: 12
WIDTH: 17
RELEASE [06.12.00.00]


Any idea why i am getting two different outputs and whats then meaning of second output.
I ran your script under ksh but when i executed test.ksh it just says,command not found.

what is your UNIX environment?

> vi test.ksh
"test.ksh" 9 lines, 72 characters

echo "Hello"

if [ $# -eq 0 ]; then
echo "bye"
else
echo "Welcome"
fi

~

~
"test.ksh" 9 lines, 86 characters
> ./test.ksh
Hello
bye
> test.ksh
test.ksh: Command not found.
>
# 4  
Old 04-08-2007
My default shell is tcsh and i am running this script on HP-UX
# 5  
Old 04-08-2007
Run the script in bash shell or and a magic element top of the script...as

Code:
#!/bin/bash

it will give the result

Last edited by srikanthus2002; 04-09-2007 at 07:53 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Asign to variable ksh some values of sql query

Hi, I'm trying to asign to ksh varible some values of a sql query. The output query would be: xxxx 1 yyyy 2 I do: values=`$PATH_UTI/query_sh " select think1||'------'||think2 from some_table where think3 = '$1'; ... (2 Replies)
Discussion started by: mierdatuti
2 Replies

2. UNIX for Dummies Questions & Answers

Extract only the data from ksh script running netezza query

Hi I searched this forum before posting the question, but couldnt find it, the issue i'm facing is, i'm trying to select a column from a netezza table from a korn shell script, but the query runs var=$(nzodbcsql -q "select MAX(millcount) from table1";) echo $var it returns the value like... (10 Replies)
Discussion started by: maximus_jack
10 Replies

3. Shell Programming and Scripting

Shell Script (ksh) - SQLPlus query filter using a string variable

Using ksh, I am using SQLPlus to execute a query with a filter using a string variable. REPO_DB=DEV1 FOLDER_NM='U_nmalencia' FOLDER_CHECK=$(sqlplus -s /nolog <<EOF CONNECT user/pswd_select@${REPO_DB} set echo off heading off feedback off select subj_name from subject where... (5 Replies)
Discussion started by: nkm0brm
5 Replies

4. Shell Programming and Scripting

Beginner in ksh - umask query

I started to learn KSH I am doing some exercises from the book $ umask =rx, u+w $ print Keep track of everythine > file1.out $ print Be careful >> file1.out ksh: file1.out: cannot create $ umask -S ... (1 Reply)
Discussion started by: solaris_user
1 Replies

5. Shell Programming and Scripting

Shell Script to execute Oracle query taking input from a file to form query

Hi, I need to query Oracle database for 100 users. I have these 100 users in a file. I need a shell script which would read this User file (one user at a time) & query database. For instance: USER CITY --------- ---------- A CITY_A B CITY_B C ... (2 Replies)
Discussion started by: DevendraG
2 Replies

6. Shell Programming and Scripting

Query Oracle tables and return values to shell script that calls the query

Hi, I have a requirement as below which needs to be done viz UNIX shell script (1) I have to connect to an Oracle database (2) Exexute "SELECT field_status from table 1" query on one of the tables. (3) Based on the result that I get from point (2), I have to update another table in the... (6 Replies)
Discussion started by: balaeswari
6 Replies

7. Shell Programming and Scripting

to find whether update query is successfull or not using Ksh Script

i have a script that performes an update operation. I just wanted to know whether that update statement is successfull or not. Below the script: #!/bin/ksh . $HOME/conf/systemProperties/EnvSetup.properties sqlplus -silent sie/da@edn.world <<END set pagesize 0 feedback off verify off... (3 Replies)
Discussion started by: ali560045
3 Replies

8. UNIX for Dummies Questions & Answers

Query a DB from another DB in ksh

I'm trying to connect to a DB on a windows server from a DB on a unix server. While I can connect, I can't seem to get the expected results back, I'm only getting the number "2" back no matter what date I put in (I should be getting "408" or "410" depending on the date). Funny, when I go into... (1 Reply)
Discussion started by: tekster757
1 Replies

9. Shell Programming and Scripting

passing result of query to a varibale in ksh script

Hi, I have a scenario where in i have to extarct max of one column and pass it to a variable. i have tried to export the result as .dat file and read from that file.But my database is mainframe and it is not permitting me to export in .dat file.I have tried using .ixf file but reading from... (2 Replies)
Discussion started by: ammu
2 Replies

10. Shell Programming and Scripting

KSH n FTP query

Hi, I have this slightly modified FTP code (thanks to this forum) function gather_FTPDate { HOST= USER= PASSWD= exec 4>${TEMP_LOG_FILE} ftp -nv >&4 2>&4 |& echo $? if ] then echo "Unable to connect to FTP server!!!" >> ${LOG_FILE} return 0 fi print -p open... (2 Replies)
Discussion started by: psynaps3
2 Replies
Login or Register to Ask a Question