Weird issue - *ksh script not recognized when being called

 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Weird issue - *ksh script not recognized when being called
# 1  
Old 10-18-2017
Weird issue - *ksh script not recognized when being called

HI Team -

I'm running into a weird issue when trying to call a .ksh script.

In my shell script, I'm using the following command to call my environment file:

Code:
cd /hypbin/test
./_env.ksh

But it's saying not found. Permissions are set correctly, shebang is set but I'm unsure why it's not recognized.

I tried the following thinking there were white spaces:
Code:
cd /hypbin/test
"./_env.ksh"

Any ideas?

Thanks!
# 2  
Old 10-18-2017
It's a bit unclear. You want to load _env.ksh into your current script?

If so, you need to source it in your script.

Code:
source ./_env.ksh
# or
. ./_env.ksh

If not, there could be a few other reasons, but it's hard to say based on the info you've given.

Can you post the shebang you're using (unless you do plan to source the file, in which case it makes no difference as it's just a comment), and an long listing of the files we're talking about?
This User Gave Thanks to Scott For This Post:
# 3  
Old 10-18-2017
HI Scott -

Thank you so much!

Shebang is as follows:

Code:
#!/usr/bin/ksh

Also source did not work as it says "source not found" and when using the . ./ method, it says ^M: not found.

The purpose is to call the _env file to set some variables.
# 4  
Old 10-18-2017
You'd probably want to get rid of those ^Ms to start with.

Code:
dos2unix # if it's installed
# or
tr -d "^M" < file > newfile # ^M = Control-V followed by Control-M

This User Gave Thanks to Scott For This Post:
# 5  
Old 10-18-2017
Wow - I feel so stupid. This was bush league!

Thank you, Scott. Sorry for the bother. Been a long week Smilie
# 6  
Old 10-18-2017
Haha. No worries Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk issue expanding variables in ksh script

Hi Guys, I have an issue with awk and variables. I have trawled the internet and forums but can't seem to get the exactt syntax I need. I have tried using awk -v and all sorts of variations but I have hit a brick wall. I have spent a full day on this and am just going round in circles. ... (3 Replies)
Discussion started by: gazza-o
3 Replies

2. Shell Programming and Scripting

AWK Variable assignment issue Ksh script

Hi There, I am writing a ksh script which assigns variable values from file "A" and passes that variables to file "B". While passing the parameters an additional "$" sign is being assigned to awk -v option. Could any one help me with this please. #!/bin/ksh head -1... (3 Replies)
Discussion started by: Jeevanm
3 Replies

3. UNIX for Advanced & Expert Users

Weird SUID issue

Hi, I am setting up SUID permissions on a binary. It gets set for most of the users, however, 1 in 10 users is unable to set these. For those who works: > chmod 6555 Test > ls -l Test -r-sr-sr-x 1 A B 5524 Nov 15 14:53 Test For those where it doesn't work: > chmod 6555 Test... (14 Replies)
Discussion started by: vibhor_agarwali
14 Replies

4. Shell Programming and Scripting

Date command does not work in a KSH when called from Cron

Hi, I'm trying to execute a job on the last day of every month, for which i'm using the following code in my Korn shell script : if ]; then echo allowed only on last day of month. Today is `date +%d` >t.stm echo Tomorrow is `date +%d -d tomorrow` >s.stm exit 0 fi ... ....... (7 Replies)
Discussion started by: devilsadvocate
7 Replies

5. Shell Programming and Scripting

KSH script SQL timeout issue

Hi all, I have a KSH script which is kicking off an sql scripts as follows: /usr/local/installs/instantclient_10_2/sqlplus -s username/password @$sql_path/sql_query.sql > $tmp_path/sql_query_results The problem I have is that sometimes the 10g Oracle Database spits out an error saying... (4 Replies)
Discussion started by: Donkey25
4 Replies

6. Shell Programming and Scripting

passing a variables value from the called script to calling script using ksh

How do i get the value of the variable from the called script(script2) to the calling script(script1) in ksh ? I've given portion of the script here to explain the problem. Portion of Script 1 ============= ----- ----- tmp=`a.ksh p1 p2 p3` if then # error processing fi -----... (10 Replies)
Discussion started by: rajarkumar
10 Replies

7. Shell Programming and Scripting

weird issue about h, g, x in SED

I have a file called merge2.t: Hi Hello how are you. </Endtag> <New> I am fine.</New> This is a test. freelong how Here is the SED: sed -n ' /<\/Endtag>/ !{ H } /<\/Endtag>/ { x p } (4 Replies)
Discussion started by: freelong
4 Replies

8. HP-UX

Weird Issue with crontab.

Hello all, Normally I'm pretty comfortable with crontab, changing and updating (done it many-a-time). But in the last two days I've been pulling my hair out over the following... Details of OS: HP-UX mdirect B.11.23 U ia64 2587410573 unlimited-user license Issue: Execute a script (very... (3 Replies)
Discussion started by: Cameron
3 Replies

9. UNIX for Advanced & Expert Users

Weird Awk issue

Hi All, a bit of a weird one here. I'm trying to pass a variable into an awk command, and I keep getting an error. I have the line nawk -F"," -v red=$random_variable '{print $red}' $w_dir/$file_name > $w_dir/${column_name} that keeps failing with the error nawk: can't open file {print... (17 Replies)
Discussion started by: Khoomfire
17 Replies

10. Shell Programming and Scripting

Need help with ksh script that uses sqlplus, called from PHP

I have a ksh script that connects to sqlplus and dumps the query results into a file. The script works file when I run it from the command line, however, when I call it from PHP using system(), exec(), or shell_exec() commands, the script doesn't seem to run the query. It will create the text file... (7 Replies)
Discussion started by: j2owilson
7 Replies
Login or Register to Ask a Question