Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Execute ksh in current environment without dot

Posted on 2014-04-04
3
Medium Priority
?
234 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

This Windows batch file is useful for organizing image files from a digital camera or other source, but can have many other uses.  It simply renames the file(s) to match their create date.  For example, if you took a picture today at 1:40pm and the …
Recently, an awarded photographer, Selina De Maeyer (http://www.selinademaeyer.com/), completed a photo shoot of a beautiful event (http://www.sintjacobantwerpen.be/verslag-en-fotoreportage-van-de-sacramentsprocessie-door-antwerpen#thumbnails) in An…
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…

604 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