?
Solved

Execute ksh in current environment without dot

Posted on 2014-04-04
3
Medium Priority
?
233 Views
Last Modified: 2014-04-04
Hi,
I need to find the way to execute scripts from main script in current environment, but not use "." (dot)  before script name
Example

#!/usr/bin/ksh
.  ~/script1
.  ~/script2

Maybe use some flag in ksh, etc...

Thanks in advance
0
Comment
Question by:IKeystone
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 39978350
Why not just

~/script1
~/script2

Where's the problem? Do you have to give back environment variables to the main script? That's the only reason for the dot I could imagine.

Of course you have to "export" variables which must be known by the called scripts.

And finally, what's wrong with the dot? Why don't you want to use it?


wmp
0
 

Author Comment

by:IKeystone
ID: 39978449
It is interactive tool I wrote. Variables going back and forward from script to script but stay inside actual session. I need to encrypt scripts but encryption tool  doesn't like dot. In tcsh it is easier (source instead dot) but I don't want to re-write all.
0
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 2000 total points
ID: 39978465
So why not "export" the variables which must be made available to called scripts?  ksh does this automatically when invoked with the "-a" flag.

To make variables set in a called script available to the calling script there is no other way than using the dot or "source", if you don't want to use an external config file.

"bash" allows using "source" instead of the dot and is widely compatible with ksh. Could  bash be an option?

Another idea: Export a variable called SOURCE in the main script:

export SOURCE="command . "

and use $SOURCE instead of the dot, like:

$SOURCE ~/script1
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
Over the years I've spent many an hour playing on hardened, DMZ'd servers, with only a sub-set of the usual GNU toy's to keep me company; frequently I've needed to save and send log or data extracts from these server back to my PC, or to others, and…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses
Course of the Month12 days, 7 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question