Mailing List Archive

Re: [EXTERNAL] RE: SSH commands to ONTAP 9.11.1P11 failing from within script
Thanks for the quick response, Jeffrey.

It's definitely not charsets although that's a good take. I already checked. I'm writing this in vim on a RHEL7.9 server. Pretty simple. Also, neither of those commands ( snapshot create? or cifs share create? ) care about the order of those options and for what it's worth both of them only exist for snapshot create? while cifs share? takes a path argument.

If I have the script echo the resulting command line and then run that from the same console, success. Only when SSHing to the filer do I get that response, for every command I send that includes the vserver? argument.

It's maddening, however you're on to something. Swapping the -vserver? and volume? arguments on the snapshot create? line, and then running it, I get a different error for that command. Both the cifs share? commands still generate the same error, but with the options swapped for the snap create? command, it barks about the validity of the volume name. (Error: Volume name: The first character must be a letter or underscore.)
So perhaps it's the terminal (PuTTY). I'll try another and see what I get.




--

Kevin Davis

Systems Administration | Sr. Storage Engineer | Information Services

UMass Memorial Health | 100 Front St. Fl 1, Worcester, MA 01608

M: 617-595-5718 | mailto:kevin.davis@umassmemorial.org

________________________________
From: Steiner, Jeffrey <Jeffrey.Steiner@netapp.com>
Sent: Monday, October 2, 2023 1:10 PM
To: Davis, Kevin <Kevin.Davis@umassmemorial.org>; toasters@teaparty.net <toasters@teaparty.net>
Subject: [EXTERNAL] RE: SSH commands to ONTAP 9.11.1P11 failing from within script


While email attachments are a popular and convenient way to send documents, they are also a common source of viruses. Use caution when opening attachments, even if they appear to have been sent by someone you know.


might this be related by charsets? I've had a LOT of problems with Windows quietly replacing a - character with a long - character that looks like a longer - when viewed in Outlook, but at the CLI it looks identica.



What happens if you swap the -vserver and the -volumes fields in the command? Does it complaint about the volume name?



From: Toasters <toasters-bounces@teaparty.net> On Behalf Of Davis, Kevin
Sent: Monday, October 2, 2023 12:03 PM
To: toasters@teaparty.net
Subject: SSH commands to ONTAP 9.11.1P11 failing from within script



NetApp Security WARNING: This is an external email. Do not click links or open attachments unless you recognize the sender and know the content is safe.



Folks something tells me this is going to be a "D'Oh!" moment, but I'm baffled.



I had a simple requirement to support an ongoing project that requires the creation of a snapshot, and a CIFS share referencing that snapshot, over a series of days. Snapshot and share name naming convention is a simple <YYYYmmdd-<string> and <YYYYmmdd-<string>$> respectively.

The intention is to create both snapshot/share a little after midnight each day until the project ends and they are no longer needed. Simple enough, right?

Well, when I run these commands via SSH from a prompt on a Linux box, everything works just fine:

[root@foo01 ~]# /bin/ssh admin@foo'snapshot create -vserver foo3 -volume Foo04 -snapshot 20231003-foo -expiry-time 11/02/2023 00:00:00'



Last login time: 10/2/2023 12:26:31



[root@foo01 ~]# /bin/ssh admin@foo 'snapshot show -vserver foo3 -volume Foo04 -snapshot 20231003-foo '



Last login time: 10/2/2023 12:46:12



Vserver: foo3

Volume: Foo04

Snapshot: 20231003-foo

Creation Time: Mon Oct 02 12:46:13 2023

Snapshot Busy: false

List of Owners: -

Snapshot Size: 14.76MB

Percentage of Total Blocks: 0%

Percentage of Used Blocks: 0%

Comment: -

7-Mode Snapshot: false

Label for SnapMirror Operations: -

Snapshot State: -

Constituent Snapshot: false

Expiry Time: 11/2/2023 00:00:00

SnapLock Expiry Time: -



However, running a script (sh or bash, makes no difference in this case), I get this when it runs. It actually doesn't matter what ONTAP command I send, they all give the same "Vserver name: Invalid." error (the /bin/ssh? lines are just echo statements in the script so I can see that it's building and sending the right command line):



/bin/ssh admin@foo 'snapshot create -vserver foo3 -volume Foo04 -snapshot 20231003-foo -expiry-time 11/02/2023 00:00:00'



Last login time: 10/2/2023 12:46:39



Error: Vserver name: Invalid. The Vserver name must begin with a letter or an

underscore. Maximum supported length: 41 if Vserver is type

"sync-source", 47 otherwise.



/bin/ssh admin@foo 'cifs share create -vserver foo3 -path /Foo04/.snapshot/20231003-foo -share-name 20231003-foo$ -share-properties oplocks,browsable,changenotify,show-previous-versions -symlink-properties symlinks -offline-files manual -vscan-fileop-profile standard -max-connections-per-share 4294967295 -comment pst migrations ok to delete after 11/02/2023 00:00:00'



Last login time: 10/2/2023 12:51:11



Error: Vserver name: Invalid. The Vserver name must begin with a letter or an

underscore. Maximum supported length: 41 if Vserver is type

"sync-source", 47 otherwise.



The script is so simple it's embarrassing. Define a few variables and optargs, build 3 simple SSH commands to send to the toaster, and run them. Everything up until these commands reach the toaster is working as expected. It just breaks when it gets there.







--

Kevin Davis

Systems Administration | Sr. Storage Engineer | Information Services

UMass Memorial Health | 100 Front St. Fl 1, Worcester, MA 01608 | mailto:kevin.davis@umassmemorial.org



The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, transmission, re-transmission, dissemination or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer.

The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, transmission, re-transmission, dissemination or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer.
Re: [EXTERNAL] RE: SSH commands to ONTAP 9.11.1P11 failing from within script [ In reply to ]
My bet is that there’s something unexpected going on with word splitting here. Try turning on tracing (set -x) before you run the ssh commands so you can see exactly what is being exec’ed after word splitting and other parsing.

Thanks,
Michael

From: Toasters <toasters-bounces@teaparty.net> on behalf of "Davis, Kevin" <Kevin.Davis@umassmemorial.org>
Date: Tuesday, October 3, 2023 at 5:55?PM
To: "Steiner, Jeffrey" <Jeffrey.Steiner@netapp.com>, "toasters@teaparty.net" <toasters@teaparty.net>
Subject: Re: [EXTERNAL] RE: SSH commands to ONTAP 9.11.1P11 failing from within script


This message was sent by an external party.

Thanks for the quick response, Jeffrey.

It's definitely not charsets although that's a good take. I already checked. I'm writing this in vim on a RHEL7.9 server. Pretty simple. Also, neither of those commands ( snapshot create? or cifs share create? ) care about the order of those options and for what it's worth both of them only exist for snapshot create? while cifs share? takes a path argument.

If I have the script echo the resulting command line and then run that from the same console, success. Only when SSHing to the filer do I get that response, for every command I send that includes the vserver? argument.

It's maddening, however you're on to something. Swapping the -vserver? and volume? arguments on the snapshot create? line, and then running it, I get a different error for that command. Both the cifs share? commands still generate the same error, but with the options swapped for the snap create? command, it barks about the validity of the volume name. (Error: Volume name: The first character must be a letter or underscore.)
So perhaps it's the terminal (PuTTY). I'll try another and see what I get.




--

Kevin Davis

Systems Administration | Sr. Storage Engineer | Information Services

UMass Memorial Health | 100 Front St. Fl 1, Worcester, MA 01608

M: 617-595-5718 | mailto:kevin.davis@umassmemorial.org

________________________________
From: Steiner, Jeffrey <Jeffrey.Steiner@netapp.com>
Sent: Monday, October 2, 2023 1:10 PM
To: Davis, Kevin <Kevin.Davis@umassmemorial.org>; toasters@teaparty.net <toasters@teaparty.net>
Subject: [EXTERNAL] RE: SSH commands to ONTAP 9.11.1P11 failing from within script

While email attachments are a popular and convenient way to send documents, they are also a common source of viruses. Use caution when opening attachments, even if they appear to have been sent by someone you know.


might this be related by charsets? I've had a LOT of problems with Windows quietly replacing a - character with a long - character that looks like a longer - when viewed in Outlook, but at the CLI it looks identica.



What happens if you swap the -vserver and the -volumes fields in the command? Does it complaint about the volume name?



From: Toasters <toasters-bounces@teaparty.net> On Behalf Of Davis, Kevin
Sent: Monday, October 2, 2023 12:03 PM
To: toasters@teaparty.net
Subject: SSH commands to ONTAP 9.11.1P11 failing from within script



NetApp Security WARNING: This is an external email. Do not click links or open attachments unless you recognize the sender and know the content is safe.




Folks something tells me this is going to be a "D'Oh!" moment, but I'm baffled.



I had a simple requirement to support an ongoing project that requires the creation of a snapshot, and a CIFS share referencing that snapshot, over a series of days. Snapshot and share name naming convention is a simple <YYYYmmdd-<string> and <YYYYmmdd-<string>$> respectively.

The intention is to create both snapshot/share a little after midnight each day until the project ends and they are no longer needed. Simple enough, right?

Well, when I run these commands via SSH from a prompt on a Linux box, everything works just fine:

[root@foo01 ~]# /bin/ssh admin@foo'snapshot create -vserver foo3 -volume Foo04 -snapshot 20231003-foo -expiry-time 11/02/2023 00:00:00'



Last login time: 10/2/2023 12:26:31



[root@foo01 ~]# /bin/ssh admin@foo 'snapshot show -vserver foo3 -volume Foo04 -snapshot 20231003-foo '



Last login time: 10/2/2023 12:46:12



Vserver: foo3

Volume: Foo04

Snapshot: 20231003-foo

Creation Time: Mon Oct 02 12:46:13 2023

Snapshot Busy: false

List of Owners: -

Snapshot Size: 14.76MB

Percentage of Total Blocks: 0%

Percentage of Used Blocks: 0%

Comment: -

7-Mode Snapshot: false

Label for SnapMirror Operations: -

Snapshot State: -

Constituent Snapshot: false

Expiry Time: 11/2/2023 00:00:00

SnapLock Expiry Time: -



However, running a script (sh or bash, makes no difference in this case), I get this when it runs. It actually doesn't matter what ONTAP command I send, they all give the same "Vserver name: Invalid." error (the /bin/ssh? lines are just echo statements in the script so I can see that it's building and sending the right command line):



/bin/ssh admin@foo 'snapshot create -vserver foo3 -volume Foo04 -snapshot 20231003-foo -expiry-time 11/02/2023 00:00:00'



Last login time: 10/2/2023 12:46:39



Error: Vserver name: Invalid. The Vserver name must begin with a letter or an

underscore. Maximum supported length: 41 if Vserver is type

"sync-source", 47 otherwise.



/bin/ssh admin@foo 'cifs share create -vserver foo3 -path /Foo04/.snapshot/20231003-foo -share-name 20231003-foo$ -share-properties oplocks,browsable,changenotify,show-previous-versions -symlink-properties symlinks -offline-files manual -vscan-fileop-profile standard -max-connections-per-share 4294967295 -comment pst migrations ok to delete after 11/02/2023 00:00:00'



Last login time: 10/2/2023 12:51:11



Error: Vserver name: Invalid. The Vserver name must begin with a letter or an

underscore. Maximum supported length: 41 if Vserver is type

"sync-source", 47 otherwise.



The script is so simple it's embarrassing. Define a few variables and optargs, build 3 simple SSH commands to send to the toaster, and run them. Everything up until these commands reach the toaster is working as expected. It just breaks when it gets there.







--

Kevin Davis

Systems Administration | Sr. Storage Engineer | Information Services

UMass Memorial Health | 100 Front St. Fl 1, Worcester, MA 01608 | mailto:kevin.davis@umassmemorial.org



The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, transmission, re-transmission, dissemination or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer.
The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, transmission, re-transmission, dissemination or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer.