Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After SSH Connection in TestCafe while executing Commands I am not able to load Aliases for them, how to handle and resolve this? #8354

Closed
yashsharma115 opened this issue Dec 17, 2024 · 1 comment
Labels
TYPE: bug The described behavior is considered as wrong (bug).

Comments

@yashsharma115
Copy link

What is your Scenario?

In TestCafe I made a SSH Connection, forming a non-interactive session, now when I execute command with aliases I am unable to execute the commands as error is coming that command not found.

If I am doing it in an interactive session, the commands are executing fine.

What is the Current behavior?

The current behaviour is that the commands with aliases are executing fine in interactive session of SSH but not in non-interactive session of SSH as aliases are not loading, if I remove the aliases and replace it with the actual command, it runs fine and no error is coming then.

What is the Expected behavior?

In non-interactive session also I want that the commands with aliases should execute fine and the aliases should load.

What is the public URL of the test page? (attach your complete example)

I have shared the Sample Code you can create sample using the steps mentioned in Steps to Reproduce.

Repo for reference - https://github.com/yashsharma115/testCafeExample

What is your TestCafe test code?

const { NodeSSH } = require('node-ssh');

const ssh = new NodeSSH();

// SSH Configuration
const sshConfig = {
host: 'your_hostname', // Replace with your server's IP or hostname
username: 'your_username', // Replace with the SSH username
password: 'your_password', // Use password or privateKey
// privateKey: '/path/to/your/private-key', // Optional if using SSH key authentication
};

async function executeSSHCommands() {
try {
// Establish SSH connection
console.log('Connecting to the server...');
await ssh.connect(sshConfig);
console.log('SSH connection established!');

// List of commands to execute
const commands = [
  'mylist'
];

// Execute commands sequentially
for (const command of commands) {
  console.log(`Executing command: ${command}`);
  const result = await ssh.execCommand(command);
  console.log(`STDOUT: ${result.stdout}`);
  console.log(`STDERR: ${result.stderr}`);
}

console.log('All commands executed successfully!');

} catch (error) {
console.error('Error during SSH execution:', error.message);
} finally {
ssh.dispose(); // Close the SSH connection
console.log('SSH connection closed.');
}
}

// Run the function
executeSSHCommands();

Your complete configuration file

No response

Your complete test report

No response

Screenshots

For Non-Interactive session by node-ssh

image

For Interactive session

image

Steps to Reproduce

I have Rocky Linux Container in which I create SSH connection and the steps followed are -

  1. Now login and create SSH connection in cmd by command -> ssh username@IP_Address.
  2. Then enter your password.
  3. After it create an alias like-> alias mylist='ls -la'.
  4. Now execute command in cmd-> mylist, you will get the output as shown above in first screenshot.
  5. Give the name to the file given above as sample code-> sshCommand.js.
  6. Then run the sample code with command-> node sshCommand.js in the terminal after installing packages testcafe and node-ssh.
  7. The output in the terminal is shown in the second screenshot above, kindly check it.
  8. The error coming-> mylist command not found

TestCafe version

3.7.0

Node.js version

16.2.0

Command-line arguments

node sshCommand.js

Browser name(s) and version(s)

No response

Platform(s) and version(s)

No response

Other

No response

@yashsharma115 yashsharma115 added the TYPE: bug The described behavior is considered as wrong (bug). label Dec 17, 2024
@testcafe-need-response-bot testcafe-need-response-bot bot added the STATE: Need response An issue that requires a response or attention from the team. label Dec 17, 2024
@Bayheck
Copy link
Collaborator

Bayheck commented Dec 23, 2024

Hello,

Unfortunately, your scenario is out of TestCafe scope. I will close this issue.

@Bayheck Bayheck closed this as completed Dec 23, 2024
@Bayheck Bayheck removed the STATE: Need response An issue that requires a response or attention from the team. label Dec 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
TYPE: bug The described behavior is considered as wrong (bug).
Projects
None yet
Development

No branches or pull requests

2 participants