For more details, please see ourCookie Policy.


Fibre Channel (SAN)

Reply
New Contributor
Posts: 4
Registered: ‎08-21-2012

setcontext: command not found

I have

 

setcontext 61

switchname

logout

 

in a file called test. When I run

 

ssh myswitch <test

 

I get

 

-rbash: setcontext: command not found

 

If I log on to the switch interactively the setcontext command works. Why doesn't it work from the file and what can I do to fix this issue? FOS 7.4.2a.

Regards,

Stuart

External Moderator
Posts: 5,541
Registered: ‎02-23-2004

Re: setcontext: command not found

@stuart.craig

 

post please output of "lscfg --show"

TechHelp24
New Contributor
Posts: 4
Registered: ‎08-21-2012

Re: setcontext: command not found

 lscfg --show

Created switches FIDs(Domain IDs):  128(ds)(5)  61(53)  71(54)  13(55)
Slot      1     2     3     4     5     6     7     8     9    10    11    12
-------------------------------------------------------------------------------
Port
 0    | 128 |  61 | 128 | 128 |  61 |     |     |  61 |     |     |     |     |
 1    |  61 | 128 | 128 | 128 |  61 |     |     |  61 |     |     |     |     |
 2    | 128 |  61 | 128 | 128 |  61 |     |     |  61 |     |     |     |     |
 3    |  61 |  61 |  61 |  61 |  61 |     |     |  61 |     |     |     |     |
 4    |  61 |  61 |  71 |  71 |  61 |     |     |  61 |     |     |     |     |
 5    | 128 |  61 | 128 | 128 |  61 |     |     |  61 |     |     |     |     |
 6    |  61 |  61 | 128 | 128 |  71 |     |     |  71 |     |     |     |     |
 7    | 128 | 128 | 128 | 128 |  71 |     |     |  71 |     |     |     |     |
 8    |  61 |  61 |  71 |  71 |  71 |     |     |  71 |     |     |     |     |
 9    |  71 |  71 | 128 | 128 |  71 |     |     |  71 |     |     |     |     |
10    |  61 |  61 | 128 | 128 |  13 |     |     |  13 |     |     |     |     |
11    | 128 | 128 |  61 |  61 | 128 |     |     | 128 |     |     |     |     |
12    |  61 | 128 | 128 | 128 | 128 |     |     | 128 |     |     |     |     |
13    | 128 |  61 |  61 |  61 | 128 |     |     | 128 |     |     |     |     |
14    | 128 |  61 |  61 |  61 | 128 |     |     | 128 |     |     |     |     |
15    | 128 | 128 |  61 | 128 | 128 |     |     | 128 |     |     |     |     |
16    | 128 |  61 |  61 | 128 |  61 |     |     |  61 |     |     |     |     |
17    | 128 |  61 |  61 | 128 |  61 |     |     |  61 |     |     |     |     |
18    | 128 | 128 | 128 | 128 |  61 |     |     |  61 |     |     |     |     |
19    | 128 | 128 | 128 | 128 |  61 |     |     |  61 |     |     |     |     |
20    | 128 |  61 | 128 | 128 |  61 |     |     |  61 |     |     |     |     |
21    | 128 | 128 | 128 | 128 |  61 |     |     |  61 |     |     |     |     |
22    | 128 |  61 | 128 | 128 |  71 |     |     |  71 |     |     |     |     |
23    |  61 |  71 |  71 | 128 |  71 |     |     |  71 |     |     |     |     |
24    |  61 | 128 | 128 | 128 |  71 |     |     |  71 |     |     |     |     |
25    | 128 | 128 | 128 | 128 |  71 |     |     |  71 |     |     |     |     |
26    | 128 |  61 | 128 | 128 |  13 |     |     |  13 |     |     |     |     |
27    | 128 | 128 | 128 | 128 | 128 |     |     | 128 |     |     |     |     |
28    | 128 | 128 | 128 | 128 | 128 |     |     | 128 |     |     |     |     |
29    | 128 | 128 | 128 | 128 | 128 |     |     | 128 |     |     |     |     |
30    | 128 |  61 | 128 | 128 | 128 |     |     | 128 |     |     |     |     |
31    |  13 |  13 |  13 |  13 | 128 |     |     | 128 |     |     |     |     |
32    |  71 |  71 |  71 |  71 |     |     |     |     |     |     |     |     |
33    |  61 |  61 | 128 | 128 |     |     |     |     |     |     |     |     |
34    |  61 |  61 | 128 | 128 |     |     |     |     |     |     |     |     |
35    |  61 |  61 | 128 | 128 |     |     |     |     |     |     |     |     |
36    |  61 |  61 | 128 | 128 |     |     |     |     |     |     |     |     |
37    | 128 | 128 | 128 | 128 |     |     |     |     |     |     |     |     |
38    | 128 | 128 | 128 | 128 |     |     |     |     |     |     |     |     |
39    |  61 | 128 | 128 | 128 |     |     |     |     |     |     |     |     |
40    | 128 | 128 | 128 | 128 |     |     |     |     |     |     |     |     |
41    | 128 | 128 | 128 | 128 |     |     |     |     |     |     |     |     |
42    | 128 | 128 | 128 | 128 |     |     |     |     |     |     |     |     |
43    | 128 | 128 | 128 | 128 |     |     |     |     |     |     |     |     |
44    | 128 | 128 |  61 | 128 |     |     |     |     |     |     |     |     |
45    |  71 | 128 | 128 | 128 |     |     |     |     |     |     |     |     |
46    |  71 | 128 |  71 |  71 |     |     |     |     |     |     |     |     |
47    |  13 | 128 | 128 | 128 |     |     |     |     |     |     |     |     |
48    |     |     |     |     |     |     |     |     |     |     |     |     |
49    |     |     |     |     |     |     |     |     |     |     |     |     |
50    |     |     |     |     |     |     |     |     |     |     |     |     |
51    |     |     |     |     |     |     |     |     |     |     |     |     |
52    |     |     |     |     |     |     |     |     |     |     |     |     |
53    |     |     |     |     |     |     |     |     |     |     |     |     |
54    |     |     |     |     |     |     |     |     |     |     |     |     |
55    |     |     |     |     |     |     |     |     |     |     |     |     |
56    |     |     |     |     |     |     |     |     |     |     |     |     |
57    |     |     |     |     |     |     |     |     |     |     |     |     |
58    |     |     |     |     |     |     |     |     |     |     |     |     |
59    |     |     |     |     |     |     |     |     |     |     |     |     |
60    |     |     |     |     |     |     |     |     |     |     |     |     |
61    |     |     |     |     |     |     |     |     |     |     |     |     |
62    |     |     |     |     |     |     |     |     |     |     |     |     |
63    |     |     |     |     |     |     |     |     |     |     |     |     |


Frequent Contributor
Posts: 88
Registered: ‎01-19-2018

Re: setcontext: command not found

The scripts with "setcontext" would not execute. I've seen this many times.

1) You either need to do setcontext manually and then execute the script - note that this needs to run from under the root account.

2) Or you need to use "fosexec" in your script. But this has some other limitations.

3) You might also configure a specific user account with specific home FID, then you might do what you are initially trying but without setcontext, as this specific user will be directly logging into the required context.
Regular Contributor
Posts: 208
Registered: ‎04-04-2018

Re: setcontext: command not found

[ Edited ]

Hello, 

 

setcontext via script is working only when you switch to default admin domain first.

 

test.h

  

ad --select AD0
setcontext 128

 

 

Unfortunatelly right now i dont have any switch with VF enabled so im expecting output message that VF is not enabled.

 

[marian.bezeg.xxxxxxx] ➤ X01 < test.sh

-----------------------------------------------------------------
lscfg_util: requires VF to be enabled.

So it looks like that setcontext is now working.

 

 

Please mark this response as "Accept as Solution" if it answers your question.

Marian Bezeg
Frequent Contributor
Posts: 88
Registered: ‎01-19-2018

Re: setcontext: command not found

Marian, as far as I know VF cannot coexist with AD, e.g. see: "Virtual Fabrics must be disabled before you create Admin Domains"

Are you sure that the command sequence you provided really helps to execute the "setcontext" in a script? Is it some kind of a undocumented workaround? I'd appreciate if you could share a bit more information on this. Thanks!
Regular Contributor
Posts: 208
Registered: ‎04-04-2018

Re: setcontext: command not found

Hello Alexey,

 

as I mentioned, right now i don't have access to switches with VF enabled so i can't test it.

Anyway AD0 is default AD which is there without any configuration on switches.

You don't need to enable/create AD.

 

I've tried this on switches where VF are disabled. I will really appreciate if someone will try it on switches where VF are currently enabled.

 

I've tried to send setcontext without ad select:

[marian.bezeg.**filtered**.xxxxxx] ➤ X05 < "setcontext"
bash: setcontext: No such file or directory

With AD select it will go ahead with setcontext command.

 

 

 

 

Please mark this response as "Accept as Solution" if it answers your question.

Marian Bezeg
Frequent Contributor
Posts: 88
Registered: ‎01-19-2018

Re: setcontext: command not found

[ Edited ]

My colleagues gave it a try and it didn't work:

 

[user@host]# cat test111
ad --select AD0
setcontext 56

 

[user@host]# ssh admin@switch < test111
Pseudo-terminal will not be allocated because stdin is not a terminal.
admin@switch's password:
Not allowed to execute in VF environment
-rbash: setcontext: command not found

 

As you can see, the "ad" command immediately fails because it can't be used in VF-enabled mode. Then "setcontext" fails as usual. Just in case, FOS is v7.4.2с here.

Regular Contributor
Posts: 208
Registered: ‎04-04-2018

Re: setcontext: command not found

[ Edited ]

Hello Alexey,

 

many thanks for your test. So i go deeper in the switch config.

 

At first the setcontext command is not linked its function itself. 

 

switch: root> type setcontext
setcontext is a function
setcontext ()
{
    if result=$(lscfg_util --switch $1); then
        eval "$result";
        execlogin;
    fi
}

Its stored in /etc/profile as global variable for interactive sessions. Unfortunatelly via remote sessions global variables are not loaded!

 

So under root its not an issue.

 

you may load global variables first and then execute setcontext.

 

. /etc/profile
setcontext 

Question there is how to get it working without root account...

 

 

Please mark this response as "Accept as Solution" if it answers your question.

Marian Bezeg
Frequent Contributor
Posts: 134
Registered: ‎03-20-2018

Re: setcontext: command not found

So, I know Brocade doesn't play well with redirects (< or >), so I wonder if that is the problem.

 

On another note, I created a set of VBA scripts that use either plink or putty, depending on what I want to do.

 

I would imagine that you could attempt something like this in your script:

 

setcontext 61&&switchname&&logout

 

The space between setcontext and 61 also might be an issue.

 

"setcontext 61&&switchname&&logout" is another option.

 

In my VBA scripts, quotes are a huge part of the whole ordeal.

Join the Broadcom Community

Get quick and easy access to valuable resources across the Broadcom Community Network.