function runCmdOnClient(cmd)
% runCmdOnClient In pool send a command back to the client for asynchronous evaluation.

%   Copyright 2013-2023 The MathWorks, Inc.

sessionObj = parallel.internal.pool.workerSession();
session = sessionObj.Session;
if isempty(sessionObj) || isempty(session)
    error(message('parallel:lang:mpi:ProfSessionNotRunning', cmd));
end
% Error messages will only be displayed in the main MATLAB command window, and
% the command will only be executed in the MATLAB client when it is idle.
session.evalOnClient(cmd);
