Solved

Execute ksh in current environment without dot

Posted on 2014-04-04
3
229 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
  • 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 500 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Mysql command line display examples 11 85
get remote physical servers and platforms 5 54
powershell code to list items in dropdown 6 89
Check for Linux process in script 7 47
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…
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
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…

856 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