What happens to the temperature and pressure when you open and then close a system? A bottle filled with air is moved into a new environment, and reaches thermal equilibrium with the environment, with a temperature $T_{env}$. The bottle now has a presure $p_1$, which is lower than the environment's, $p_{env}$. The cap of the bottle is removed and put back after a very short period of time. What then happends to the pressure and the temperature of the bottle? And can we consider the both the state before the cap is removed, and after the cap is put back as closed systems?
Here is my understanding:
The pressure of the bottle instantly equalizes with the environtment, so $p_2=p_{env}$. Because of the sudden change in pressure, the temperature of the bottle changes to $T_2$. Now we put the cap back and I assume $T_2$ has not changed yet. But now the bottle will exchange heat and reach thermal equilibrium. This change in temperature results in  a change of the pressure. 
I am asked to explain this with the First law of Thermodynamics, $\Delta U = Q-W$, but the First law can only be used for closed systems, and we quite clearly open our system. Is it because we only consider the two closed states, before and after the cap is moved? But in that case I don't believe the energy should be conserved, because of the interaction with the environment.
Note: I have heavily edited this post to better reflect a general situation.
 A: I feel I may be being naive, or missing the point of the question, but it seems the paucity of information drives the answer.
My first question is, would you not expect the pressures to equalise? In which case, $p_2$ = $p_{env}$, and your problem resolves to :
$$ \frac{p_1}{T_{env}}= \frac{p_{env}}{T_2}$$
with 3 knowns, 1 unknown (if that's the correct equation to use).
However, if that isn't the case, for example the bottle has a narrow opening and pressure hasn't equalised fully, then you simply wouldn't have enough information to decide what intermediate pressure is reached, when its closed again.  In which case the problem would be self evidently indeterminate anyway - it could have one of many combinations of temp + pressure depending how narrow the opening was etc.
As that's clearly not intended, the answer can only be that pressure is equalised  and you have 3 knowns, 1 unknown as above.
But you need to think a bit more, before being sure the answer is that simple
The reason I've said "if that's the correct equation", is that of course, a change in pressure means a change of volume. Meaning if  $p_1$ > $p_{env}$, the air inside has expanded and some was lost to the environment. If $p_1$ < $p_{env}$, the air inside has compressed, and some air from the external environment has entered the bottle.
You may need to think about how that affects the outcome, but it shouldn't be hard since I think we can safely assume it reaches pressure equilibrium, for reasons given above.
We must also assume (reasonably for homework) that nothing else happens.  For example "air" is not a pure or ideal gas. It contains moisture that can behave very differently from an ideal gas. There could be phase changes (liquid to gas). The air inside and out could be different (its a "different environment").  If it or the outside air are a mix of gasses, each gas has its own partial pressure.
So there are assumptions,you're assuming at minimum, that the "air"/gas in both environments is the same, and behaves ideally in all temperatures and pressures involved. Really they should specify "ideal gas", not air, and that its the same gas in both environments. Air and gas aren't the same thing at all.
