Giter VIP home page Giter VIP logo

Comments (8)

windvalley avatar windvalley commented on May 26, 2024

@arozehnal The reason is that the last command in the command sequence, touch /tmp/pokus, has a return code of 0, which indicates success. You can replace the commands as follows:
"cd /tmp && touch /tmp/pokus" or "set -e; cd /tmp; touch /tmp/pokus"

from gossh.

arozehnal avatar arozehnal commented on May 26, 2024

OK, the command sequence, that seems like a reasonable explanation at first glance
but the reality is different :-(

First... whichever of the two I run:
"set -e; cd /tmp; touch /tmp/pokus"
"cd /tmp && touch /tmp/pokus"

the result is still the same:
[INFO] 2024-03-03 14:16:33.272838 success count: 1, failed count: 0, elapsed: 0.31s

and the file is still not created

second) the cause is probably hidden behind the source of the message
chdir: error retrieving current directory: getcwd: cannot access parent directories:
which current/parent dir is this?

========================

Debug message:
execute command 'sudo -u roze -H bash -c 'cd /tmp && touch /tmp/pokus'' success, output: shell-init:
indicates the use of the '-H bash' option
Wwhat is this option? I don't see it in the gossh documentation.

My default shell is 'ksh' can't too be causing the problem?

from gossh.

arozehnal avatar arozehnal commented on May 26, 2024

I tried both variants of the chained commands by changing my ksh to bash before running gossh on the source, respectively I set bash as default to both logins roze and roze2 on the target server.

The result is still the same though. :-(

===================

simple test chained commands
bash-5.1$ ls a*
a # OK, just 'a' exists

bash-5.1$ ls a aa; echo $?
aa not found
a
2 # as expected

bash-5.1$ cat a|wc -l; echo $?
0
0 # as expected

bash-5.1$ cat aa|wc -l; echo $?
cat: cannot open aa # as expected
0
0 # hmm, strange

set -o pipefail; cat aa|wc -l; echo $?
cat: cannot open aa # as expected
0 #
2 # finally as expected

and the worst news at the end...
AIX ksh does not support 'set pipefail'

from gossh.

windvalley avatar windvalley commented on May 26, 2024

Sorry, I can't reproduce the issue you are encountering. I don't have an AIX environment, but I set up a ksh environment on my virtual machine(CentOS7.9) as remote host and mocked the users(using ksh) and actions as yours, then executed the command like gossh command kom -U roze -s -e "cd /tmp; touch /tmp/pokus " -v -p ...., but everything is ok, no warnings, no errors, and the file /tmp/pokus was successfully created.

For you saying 'AIX ksh does not support set pipefail', if your AIX server has bash installed, there shouldn't be a problem with it, coz as you know gossh use bash to run commands.

from gossh.

arozehnal avatar arozehnal commented on May 26, 2024

I'm not surprised by the different behaviour of AIX ksh from other shells, I've been living with it for 20 years :-(.
AIX is quite exotic and closed in some cases. And their native KSH is an exemplary case.
Unfortunately, I'm working on a project that has been in development for over 20 years, and the primary shell in it is that basic AIX ksh.

I really like gossh and would like to use them, I understand that it's hard to give support for what I don't have access to.
But I still think that maybe in this case there might be a problem with the parrent directory rights.
It behaves pretty much like that demo of chained commands in bash with/without using pipefail.

I run gossh from the home directory of roze2 (/home/roze2), on the target and I want to create a file in /tmp on the target..
I run gossh on the source as roze, but on the target I execute the action as roze2.
I have three questions:

  1. the problem is on source or target server?
  2. is the shell problem of roze or roze2
  3. where is the source of the message:
    chdir: error retrieving current directory: getcwd: cannot access parent directories:
    Which directory is it? /home /tmp ...?

It is not clear from the gossh debug module.

So far I have tried changing the default shell for both roze and roze2 on the target to bash but the result is still the same.

from gossh.

windvalley avatar windvalley commented on May 26, 2024
  1. on target server
  2. not sure
  3. not sure. I guess it may be the $HOME of roze2 on target server if the raw command is like sudo -u roze2 -H bash -c ''.

Please list results of the followings commands on target server:

  1. ls -ld /tmp
  2. ls -ld xxx(home of roze)
  3. ls -ld xxx(home of roze2)

In addition, login the target server with 'roze', then execute sudo -u roze2 -H bash -c 'cd /tmp; touch /tmp/pokus'. Can it run successfully? If not, paste the outputs.

from gossh.

arozehnal avatar arozehnal commented on May 26, 2024

I have only good news :-)

  • the error message "chdir: error retrieving current directory: getcwd:" has stopped appearing
  • /tmp/pokus was created with the correct attributes
  • incorrect initial command of the chained commands, it is correctly detected and notified
  • all this using by default AIX ksh and without set pipefail

I just don't know what caused the problems so far. When trying to change the default shell, I did the straightforward thing of canceling the roze2 login and then setting it up with a regular AIX routine. So probably something wrong when creating the user (?).

Thank you very much for your patience and willingness to help.

One last question (I promise this is the last question for this week :-) :-))
I will run using gossh scripts on about 80-100 target servers, the scripts have short outputs on STDOUT, maximum 50-100 lines of text.
Is there any reason to use "-c int"? How many concurrent sessions would you choose?

from gossh.

windvalley avatar windvalley commented on May 26, 2024

@arozehnal If you do not use the -c flag, it will SSH all servers serially, which is less efficient. As for how many concurrent sessions to set, it really depends. If you have 4Cores and 8GB of available resources(source server), I think setting it to 100 concurrent sessions is not a problem. Of course, I still recommend that you test and find the most efficient number based on your actual conditions:)

from gossh.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.