Author Topic: set echo off when using ovitos with sftp  (Read 426 times)

shyoo

  • Newbie
  • *
  • Posts: 5
set echo off when using ovitos with sftp
« on: February 20, 2019, 07:24:01 AM »
Hello.

When I run Python script by 'ovitos', I want to connect sftp server and load dump file made by LAMMPS. In this case, 'ovitos' ask the ssh username and password in terminal. The terminal shows 'set echo off beforehand!' when typing my password. How can I set echo off? is it related to the terminal preference or not?

Thanks.

Alexander Stukowski

  • Administrator
  • Hero Member
  • *****
  • Posts: 638
Re: set echo off when using ovitos with sftp
« Reply #1 on: February 20, 2019, 09:18:08 AM »
Hi,

That's a good question. I never thought about it before. The "set echo off beforehand!" message is meant as a warning to you, because Ovito has no way of concealing your keyboard input when you enter the password. Thus, the password will appear as clear text in the terminal and every bystander can potentially see it.

Unix/Linux terminals, however, provide a way to hide all keyboard input entered by the user. You can activate this mode using the "stty -echo" terminal command (to reactivate the display again use "stty echo"). You need to activate the "echo-off" mode before running ovitos.

https://egloo.wordpress.com/2008/10/13/turn-off-echo-in-a-terminal/

Note that newer versions of Ovito provide support for public-key SSH authentication. Thus, if you use this type of authentication instead of password authentication, the above problem is no longer an issue and you have the advantage of your ovitos script running without any user intervention.

-Alex
« Last Edit: February 20, 2019, 09:21:29 AM by Alexander Stukowski »

shyoo

  • Newbie
  • *
  • Posts: 5
Re: set echo off when using ovitos with sftp
« Reply #2 on: February 20, 2019, 10:54:39 AM »
Thank you for fast reply.

-SangHyuk Yoo

shyoo

  • Newbie
  • *
  • Posts: 5
Re: set echo off when using ovitos with sftp
« Reply #3 on: February 21, 2019, 08:56:25 AM »
Dear Alex,

I have another question during using sftp. In my script, my username and address of the sftp was written.
But terminal asked me to enter my username of the sftp again.
Is there a solution?

-SangHyuk Yoo

Alexander Stukowski

  • Administrator
  • Hero Member
  • *****
  • Posts: 638
Re: set echo off when using ovitos with sftp
« Reply #4 on: February 21, 2019, 09:51:00 AM »
No, normally this should not happen. Can you please post the script so I can see how you specify the SFTP address?

If you have switched to Ovito 3.0.0-dev already, you can activate verbose log messages by setting the OVITO_SSH_LOG environment variable. This will show you more information about the SSH connection and authentication process:

Code: [Select]
export OVITO_SSH_LOG=1
./ovitos your_script.py

Note that you can test the SSH/SFTP remote file access also from within the graphical Ovito program. If it works there, it should also work the same way from a Python script.

shyoo

  • Newbie
  • *
  • Posts: 5
Re: set echo off when using ovitos with sftp
« Reply #5 on: February 27, 2019, 01:37:12 AM »
Sorry to late reply.
Now, I'm using Ovito 2.9.0. Here is my Python script.
If there is any problem, please let me know.

-SangHyuk Yoo

Code: [Select]
from ovito.io import *
from ovito.modifiers import *
from ovito.data import *
import numpy as np
import timeit

# define PKA speceis
PKASpecies = "Ga"
# define PKA energy range
PKAEnergy = np.array([1, 2, 5, 10, 20, 50])
# define testing number
testNum = range(1,6)
# define number of native defects
numDefects = 6

for i in PKAEnergy:
    for j in testNum:
        # check elapsed time
        tic=timeit.default_timer()
        # define output file name
        fileNameOut = PKASpecies + "_" + str(i) + "keV_test" + str(j) + ".txt"
        # open output text file
        fOut = open(fileNameOut,'w')

        # define address of the file
        sftpAddress = "sftp://myID@clusterName.yonsei.ac.kr:"
        fileAddress = "/home/shyoo/Codes/Lammps/work/GaN_PKA_SW/" + \
            str(i) + "keV_" + PKASpecies + "_random/test" + str(j) + "/dump.*.gz"
        fileNameIn = sftpAddress + fileAddress

        # import dump file
        node = import_file(fileNameIn)
        # apply modifier: WZ analysis
        mod = WignerSeitzAnalysisModifier(per_type_occupancies=True)
        fileAddress_ref = "/home/myID/Codes/Lammps/work/GaN_PKA_SW/" + \
            str(i) + "keV_" + PKASpecies + "_random/test" + str(j) + "/dump.0.gz"
        mod.reference.load(sftpAddress + fileAddress_ref)
        node.modifiers.append(mod)

        for frame in range(node.source.num_frames):
            # conduct WZ analysis at each frame
            node.compute(frame)
            # save occupancy
            occupancies = node.output.particle_properties['Occupancy'].array
            # save particle type as site_type
            site_type = node.output.particle_properties.particle_type.array
            # compute total occuapancy
            total_occupancy = np.sum(occupancies, axis=1)
            # create new particle property from selection property
            selection = node.output.create_particle_property(ParticleProperty.Type.Selection).marray
            selection = np.vstack([selection]*numDefects)

            # Ga single vacancy
            selection[0,:] = (site_type == 1) & (total_occupancy == 0)
            # N antisite (N_Ga)
            selection[1,:] = (site_type == 1) & (occupancies[:,1] == 1) & (total_occupancy == 1)
            # Ga single interstitial
            selection[2,:] = ((site_type == 1) & (occupancies[:,0] == 2) & \
                (occupancies[:,1] == 0) & (total_occupancy == 2)) ^ \
                ((site_type == 2) & (occupancies[:,0] == 1) & \
                (occupancies[:,1] == 1) & (total_occupancy == 2))         
            # N single vacancy
            selection[3,:] = (site_type == 2) & (total_occupancy == 0)
            # Ga antisite (Ga_N)
            selection[4,:] = (site_type == 2) & (occupancies[:,0] == 1) & (total_occupancy == 1)
            # N single interstitial
            selection[5,:] = ((site_type == 2) & (occupancies[:,0] == 0) & \
                (occupancies[:,1] == 2) & (total_occupancy == 2)) ^ \
                ((site_type == 1) & (occupancies[:,0] == 1) & \
                (occupancies[:,1] == 1) & (total_occupancy == 2))               
   
            # compute total number of native defects
            node.output.attributes['V_Ga'] = np.count_nonzero(selection[0,:])
            node.output.attributes['N_Ga'] = np.count_nonzero(selection[1,:])
            node.output.attributes['Ga_i'] = np.count_nonzero(selection[2,:])
            node.output.attributes['V_N'] = np.count_nonzero(selection[3,:])
            node.output.attributes['Ga_N'] = np.count_nonzero(selection[4,:])
            node.output.attributes['N_i'] = np.count_nonzero(selection[5,:])

            # print total number of native defects
            fOut.write("%d %d %d %d %d %d %d %d %d\n" \
                 % (node.output.attributes['Timestep'],
                node.output.attributes['V_Ga'],node.output.attributes['N_Ga'],
                node.output.attributes['Ga_i'],node.output.attributes['V_N'],
                node.output.attributes['Ga_N'],node.output.attributes['N_i'],
                node.output.attributes['WignerSeitz.vacancy_count'],
                node.output.attributes['WignerSeitz.interstitial_count']))

        # close output text file
        fOut.close()
        # check elapsed time
        toc = timeit.default_timer()
        elapsedTime = toc - tic
        print('Complete %s - %d keV - test %d: Elapsed time = %f' % (PKASpecies, i, j, elapsedTime))
« Last Edit: February 27, 2019, 01:39:18 AM by shyoo »

shyoo

  • Newbie
  • *
  • Posts: 5
Re: set echo off when using ovitos with sftp
« Reply #6 on: March 11, 2019, 09:00:58 AM »
I found that 'ovitos' asked me ID even though the ID was written in the script when using 'ovito 2.9.0'. However, ovito 3.0.0-dev did not require my ID when I write down my ID in a Python script.

-SangHyuk Yoo

Alexander Stukowski

  • Administrator
  • Hero Member
  • *****
  • Posts: 638
Re: set echo off when using ovitos with sftp
« Reply #7 on: March 11, 2019, 11:48:21 AM »
Thanks for letting us know.

I'm not sure why Ovito 2.9.0 ignores the username you provide as part of the SFTP URL, but since it seems to work with the current development build, I won't take further actions for now. Let me know if you need anything else.