Saumya Ranjan
Saumya Ranjan

Reputation: 75

I Want to connect from local mac host to SAS linux server remotely using python in local mac

I am trying below code :

sas = saspy.SASsession(cfgname='ssh', resutls='html',cfgfile='/Users/saumya.rb/opt/anaconda3/lib/python3.7/site-packages/saspy/sascfg.py')

error :

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/saumya.rb/opt/anaconda3/lib/python3.7/site-packages/saspy/sasbase.py", line 415, in __init__
    self.sascfg            = SASconfig(**kwargs)
  File "/Users/saumya.rb/opt/anaconda3/lib/python3.7/site-packages/saspy/sasbase.py", line 130, in __init__
    SAScfg = self._find_config(cfg_override=kwargs.get('cfgfile'))
  File "/Users/saumya.rb/opt/anaconda3/lib/python3.7/site-packages/saspy/sasbase.py", line 267, in _find_config
    SAScfg = importlib.import_module(tempname)
  File "/Users/saumya.rb/opt/anaconda3/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 724, in exec_module
  File "<frozen importlib._bootstrap_external>", line 860, in get_code
  File "<frozen importlib._bootstrap_external>", line 791, in source_to_code
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/var/folders/pr/w_hplw1j7bl0vj2yj97_dd5mv3j_2t/T/tmp1bi7td8v/sascfg005.py", line 88
    'ssh'     : '/usr/bin/ssh',
              ^
SyntaxError: invalid syntax

please share me the details like which python version I should use. what should be my sascfg.py look like

I am using Python 3.7.4 (default, Aug 13 2019, 15:17:50) [Clang 4.0.1 (tags/RELEASE_401/final)] :: Anaconda, Inc. on darwin

using below config :

default  = {'saspath'  : '/sashome/compute/SASFoundation/9.4/sas'
            'ssh'      : '/usr/bin/ssh',
            'options'  : ["-fullstimer", "-autoexec", "/SAS9.4/SASConfig_bkp/compute/Lev1/SASApp/StoredProcessServer/autoexec.sas"],
            'autoexec' : "libname mylib '/ngs/app/sasp';",
            'host'     : 'remote.linux.host',
            'options'  : ["-fullstimer"]
            }


#ssh      = {'saspath' : '/opt/sasinside/SASHome/SASFoundation/9.4/bin/sas_en',
#            'ssh'     : '/usr/bin/ssh',
#            'host'    : 'remote.linux.host', 
#            'encoding': 'latin1',
#            'options' : ["-fullstimer"]
#            }
#
ssh      = {'saspath'  : '/sashome/compute/SASFoundation/9.4/sas'
            'ssh'      : '/usr/bin/ssh',
            'options'  : ["-fullstimer", "-autoexec", "/ngs/app/sasp/SAS9.4/SASConfig_bkp/compute/Lev1/SASApp/StoredProcessServer/autoexec.sas"],
            'autoexec' : "libname mylib '/ngs/app/sasp';",
            'host'     : 'remote.linux.host',
            'options'  : ["-fullstimer"]
            }

Upvotes: 0

Views: 617

Answers (2)

Tom
Tom

Reputation: 68

Now addressing the errror recieved after fixing the syntax error. AttributeError: module 'os' has no attribute 'waitid' The STDIO access method uses this waitid method, but it isn't in the Mac version of Python. I reworked that access method to use waitpid instead of waitid and it resolved this problem, and now this access method works from a Mac client. Specifically, it's STDIO over SSH, as SAS doens't runn locally on a Mac. See saspy issue https://github.com/sassoftware/saspy/issues/288 for details about this fix.

This code is at master at the moment, but it will be in the next release I build; V3.3.5 Looking into one other issue to be sure it's not specific to the Mac. Will build this new release once that's addressed.

Saumya Ranjan, are you able to verify this fix?

Thanks, Tom

Upvotes: 0

Tom
Tom

Reputation: 68

the error you got is because you're missing a comma between dictionary entries:

ssh = {'saspath' : '/sashome/compute/SASFoundation/9.4/sas' 'ssh' : '/usr/bin/ssh',

you need a comma after your path specification.

As for autoexec, the one listed in the options is for the remote SAS session to load and run, while the saspy autoexec is what saspy will submit for you after the session is up and connected to. So, these are two slightly different things.

Add in the comma and get rid of this syntax error and see what you get.

Thanks, Tom

Upvotes: 2

Related Questions